diff options
author | Calvin Lee <cyrus296@gmail.com> | 2017-04-02 14:38:33 -0600 |
---|---|---|
committer | Calvin Lee <cyrus296@gmail.com> | 2017-04-03 11:48:37 -0600 |
commit | 2445d279604d7be38c00db60ffde4279a3c75459 (patch) | |
tree | 030844d9fb13be7814dd760a6ffedbec8f5264cd /sway/border.c | |
parent | ab7570d311d65ff03fd14627ec3157fa37995ced (diff) |
Impliment i3-style marks
This commit adds three commands to sway: `show_marks`, `mark` and
`unmark`. Marks are displayed right-aligned in the window border as i3
does. Marks may be found using criteria.
Fixes #1007
Diffstat (limited to 'sway/border.c')
-rw-r--r-- | sway/border.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sway/border.c b/sway/border.c index d79029a9..10ad92c2 100644 --- a/sway/border.c +++ b/sway/border.c @@ -1,8 +1,11 @@ +#define _XOPEN_SOURCE 500 #include <wlc/wlc-render.h> #include <cairo/cairo.h> #include <pango/pangocairo.h> #include <stdlib.h> #include <stdio.h> +#include <string.h> +#include <strings.h> #include <arpa/inet.h> #include "sway/border.h" #include "sway/container.h" @@ -190,6 +193,26 @@ static void render_title_bar(swayc_t *view, cairo_t *cr, struct wlc_geometry *b, cairo_set_source_u32(cr, colors->text); pango_printf(cr, config->font, 1, false, "%s", view->name); } + // Marks + if (config->show_marks && view->marks) { + int total_len = 0; + + for(int i = view->marks->length - 1; i >= 0; --i) { + char *mark = (char *)view->marks->items[i]; + if (*mark != '_') { + int width, height; + get_text_size(cr, config->font, &width, &height, 1, false, "[%s]", mark); + total_len += width; + if ((int)tb->size.w + x - (total_len + 2) < x + 2) { + break; + } else { + cairo_move_to(cr, (int)tb->size.w + x - (total_len + 2), y + 2); + cairo_set_source_u32(cr, colors->text); + pango_printf(cr, config->font, 1, false, "[%s]", mark); + } + } + } + } // titlebars has a border all around for tabbed layouts if (view->parent->layout == L_TABBED) { |