all repos — tint2 @ 008eebe4b1238c827e76b8c77aee1231f61a748f

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

When WM_HINTS changes for a window, reload the icon
o9000 mrovi9000@gmail.com
commit

008eebe4b1238c827e76b8c77aee1231f61a748f

parent

cbb76849ea2a3e083508c463fb099edd9043f636

2 files changed, 26 insertions(+), 16 deletions(-)

jump to
M src/taskbar/task.csrc/taskbar/task.c

@@ -268,21 +268,26 @@ }

Imlib_Image img = NULL; - int i; - gulong *data = server_get_property(task->win, server.atom._NET_WM_ICON, XA_CARDINAL, &i); - if (data) { - // get ARGB icon - int w, h; - gulong *tmp_data; + if (!img) { + int i; + gulong *data = server_get_property(task->win, server.atom._NET_WM_ICON, XA_CARDINAL, &i); + if (data) { + // get ARGB icon + int w, h; + gulong *tmp_data; - tmp_data = get_best_icon(data, get_icon_count(data, i), i, &w, &h, panel->g_task.icon_size1); - DATA32 icon_data[w * h]; - for (int j = 0; j < w * h; ++j) - icon_data[j] = tmp_data[j]; - img = imlib_create_image_using_copied_data(w, h, icon_data); - XFree(data); - } else { - // get Pixmap icon + tmp_data = get_best_icon(data, get_icon_count(data, i), i, &w, &h, panel->g_task.icon_size1); + DATA32 icon_data[w * h]; + for (int j = 0; j < w * h; ++j) + icon_data[j] = tmp_data[j]; + img = imlib_create_image_using_copied_data(w, h, icon_data); + if (img) + fprintf(stderr, "%s: Got %dx%d icon via _NET_WM_ICON for %s\n", __FUNCTION__, w, h, task->title ? task->title : "task"); + XFree(data); + } + } + + if (!img) { XWMHints *hints = XGetWMHints(server.display, task->win); if (hints) { if (hints->flags & IconPixmapHint && hints->icon_pixmap != 0) {

@@ -292,17 +297,20 @@ int icon_x, icon_y;

uint border_width, bpp; uint w, h; - // printf(" get pixmap\n"); XGetGeometry(server.display, hints->icon_pixmap, &root, &icon_x, &icon_y, &w, &h, &border_width, &bpp); imlib_context_set_drawable(hints->icon_pixmap); img = imlib_create_image_from_drawable(hints->icon_mask, 0, 0, w, h, 0); + if (img) + fprintf(stderr, "%s: Got %dx%d pixmap icon via WM_HINTS for %s\n", __FUNCTION__, w, h, task->title ? task->title : "task"); } XFree(hints); } } + if (img == NULL) { imlib_context_set_image(default_icon); img = imlib_clone_image(); + fprintf(stderr, "%s: Using default icon for %s\n", __FUNCTION__, task->title ? task->title : "task"); } // transform icons

@@ -348,7 +356,7 @@ imlib_free_image();

GPtrArray *task_buttons = get_task_buttons(task->win); if (task_buttons) { - for (i = 0; i < task_buttons->len; ++i) { + for (int i = 0; i < task_buttons->len; ++i) { Task *task2 = g_ptr_array_index(task_buttons, i); task2->icon_width = task->icon_width; task2->icon_height = task->icon_height;
M src/tint.csrc/tint.c

@@ -1203,6 +1203,8 @@ if (wmhints && wmhints->flags & XUrgencyHint) {

add_urgent(task); } XFree(wmhints); + task_update_icon(task); + panel_refresh = TRUE; } if (!server.got_root_win)