diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2014-07-09 22:50:42 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2014-07-09 22:50:42 +0200 |
commit | a7105a4f0ad16efc376f5b2cce386565ed9990fe (patch) | |
tree | 7567b179500ae4ae6ef12c4fcf34fd5e6813ba74 /x11-wm | |
parent | 0b5d467a88e7e5d6b43dd1d890f8f898d3228112 (diff) | |
download | patches-a7105a4f0ad16efc376f5b2cce386565ed9990fe.tar.gz patches-a7105a4f0ad16efc376f5b2cce386565ed9990fe.tar.bz2 patches-a7105a4f0ad16efc376f5b2cce386565ed9990fe.zip |
[i3] Port i3bar-icons patch
Diffstat (limited to 'x11-wm')
-rw-r--r-- | x11-wm/i3-4.8/i3bar-icons.patch | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/x11-wm/i3-4.8/i3bar-icons.patch b/x11-wm/i3-4.8/i3bar-icons.patch new file mode 100644 index 0000000..d9eb622 --- /dev/null +++ b/x11-wm/i3-4.8/i3bar-icons.patch @@ -0,0 +1,143 @@ +diff --git a/common.mk b/common.mk +index b086bc8..a7b263c 100644 +--- a/common.mk ++++ b/common.mk +@@ -82,6 +82,7 @@ XCB_CFLAGS := $(call cflags_for_lib, xcb) + XCB_CFLAGS += $(call cflags_for_lib, xcb-event) + XCB_LIBS := $(call ldflags_for_lib, xcb,xcb) + XCB_LIBS += $(call ldflags_for_lib, xcb-event,xcb-event) ++XCB_LIBS += $(call ldflags_for_lib, xcb-image,xcb-image) + ifeq ($(shell pkg-config --exists xcb-util 2>/dev/null || echo 1),1) + XCB_CFLAGS += $(call cflags_for_lib, xcb-atom) + XCB_CFLAGS += $(call cflags_for_lib, xcb-aux) +diff --git a/i3bar/include/common.h b/i3bar/include/common.h +index d63780d..b0b0394 100644 +--- a/i3bar/include/common.h ++++ b/i3bar/include/common.h +@@ -10,6 +10,7 @@ + #include <stdbool.h> + #include <xcb/xcb.h> + #include <xcb/xproto.h> ++#include <xcb/xcb_image.h> + #include "libi3.h" + #include "queue.h" + +@@ -38,6 +39,7 @@ struct status_block { + i3String *full_text; + + char *color; ++ char *icon; + uint32_t min_width; + blockalign_t align; + +@@ -56,6 +58,7 @@ struct status_block { + /* Optional */ + char *name; + char *instance; ++ xcb_image_t *icon_image; + + TAILQ_ENTRY(status_block) blocks; + }; +@@ -69,6 +72,7 @@ TAILQ_HEAD(statusline_head, status_block) statusline_head; + #include "workspaces.h" + #include "mode.h" + #include "trayclients.h" ++#include "xbm.h" + #include "xcb.h" + #include "config.h" + #include "libi3.h" +diff --git a/i3bar/src/child.c b/i3bar/src/child.c +index 5867ce4..0e618bf 100644 +--- a/i3bar/src/child.c ++++ b/i3bar/src/child.c +@@ -141,6 +141,7 @@ static int stdin_start_array(void *context) { + FREE(first->color); + FREE(first->name); + FREE(first->instance); ++ FREE(first->icon); + TAILQ_REMOVE(&statusline_head, first, blocks); + free(first); + } +@@ -187,6 +188,9 @@ static int stdin_string(void *context, const unsigned char *val, size_t len) { + if (strcasecmp(ctx->last_map_key, "color") == 0) { + sasprintf(&(ctx->block.color), "%.*s", len, val); + } ++ if (strcasecmp(ctx->last_map_key, "icon") == 0) { ++ sasprintf(&(ctx->block.icon), "%.*s", len, val); ++ } + if (strcasecmp(ctx->last_map_key, "align") == 0) { + if (len == strlen("left") && !strncmp((const char *)val, "left", strlen("left"))) { + ctx->block.align = ALIGN_LEFT; +@@ -246,6 +250,7 @@ static int stdin_end_array(void *context) { + TAILQ_FOREACH (current, &statusline_head, blocks) { + DLOG("full_text = %s\n", i3string_as_utf8(current->full_text)); + DLOG("color = %s\n", current->color); ++ DLOG("icon = %s\n",current->icon); + } + DLOG("end of dump\n"); + return 1; +diff --git a/i3bar/src/xcb.c b/i3bar/src/xcb.c +index a29f909..28f2b23 100644 +--- a/i3bar/src/xcb.c ++++ b/i3bar/src/xcb.c +@@ -134,6 +134,14 @@ void refresh_statusline(void) { + + block->width = predict_text_width(block->full_text); + ++ if (block->icon) { ++ block->icon_image = get_icon(block->icon); ++ if (!block->icon_image) ++ ELOG("Could not load icon: %s\n",block->icon); ++ else ++ statusline_width += block->icon_image->width+1; ++ } ++ + /* Compute offset and append for text aligment in min_width. */ + if (block->min_width <= block->width) { + block->x_offset = 0; +@@ -179,6 +187,18 @@ void refresh_statusline(void) { + + uint32_t colorpixel = (block->color ? get_colorpixel(block->color) : colors.bar_fg); + set_font_colors(statusline_ctx, colorpixel, colors.bar_bg); ++ ++ if (block->icon_image) { ++ int h = (font.height-block->icon_image->height)/2; ++ set_icon_color(xcb_connection,statusline_ctx, ++ colorpixel,colors.bar_bg); ++ xcb_image_put(xcb_connection,statusline_pm,statusline_ctx, ++ block->icon_image,x,h,0); ++ set_icon_color(xcb_connection,statusline_ctx, ++ get_colorpixel("#666666"),colors.bar_bg); ++ x+=block->icon_image->width+1; ++ } ++ + draw_text(block->full_text, statusline_pm, statusline_ctx, x + block->x_offset, 1, block->width); + x += block->width + block->x_offset + block->x_append; + +@@ -1035,6 +1055,9 @@ char *init_xcb_early() { + /* Now we get the atoms and save them in a nice data structure */ + get_atoms(); + ++ /* Set the format for icons */ ++ set_format(xcb_connection,1,1); ++ + char *path = root_atom_contents("I3_SOCKET_PATH", xcb_connection, screen); + + if (xcb_request_failed(sl_pm_cookie, "Could not allocate statusline-buffer") || +@@ -1682,6 +1705,7 @@ void draw_bars(bool unhide) { + DLOG("Drawing Bars...\n"); + int i = 0; + ++ xbm_clear_cache_used(); + refresh_statusline(); + + i3_output *outputs_walk; +@@ -1844,6 +1868,8 @@ void draw_bars(bool unhide) { + hide_bars(); + } + ++ xbm_free_unused_icons(); ++ + redraw_bars(); + } + |