When WM_HINTS changes for a window, reload the icon
This commit is contained in:
parent
cbb76849ea
commit
008eebe4b1
2 changed files with 26 additions and 16 deletions
|
@ -268,21 +268,26 @@ void task_update_icon(Task *task)
|
|||
|
||||
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 @@ void task_update_icon(Task *task)
|
|||
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 @@ void task_update_icon(Task *task)
|
|||
|
||||
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;
|
||||
|
|
|
@ -1203,6 +1203,8 @@ void event_property_notify(XEvent *e)
|
|||
add_urgent(task);
|
||||
}
|
||||
XFree(wmhints);
|
||||
task_update_icon(task);
|
||||
panel_refresh = TRUE;
|
||||
}
|
||||
|
||||
if (!server.got_root_win)
|
||||
|
|
Loading…
Reference in a new issue