all repos — tint2 @ a08491c122981590f1d5fa2108953d6a86915b10

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

Workaround for empty systray icon in Google Chrome (misbehaving) - fix sorting
o9000 o9000
commit

a08491c122981590f1d5fa2108953d6a86915b10

parent

8795f50bb8b1800cbf0a16ab966e3120fd75bb77

3 files changed, 36 insertions(+), 22 deletions(-)

jump to
M src/config.csrc/config.c

@@ -613,13 +613,13 @@ systray.area.bg = &g_array_index(backgrounds, Background, id);

} else if (strcmp(key, "systray_sort") == 0) { if (strcmp(value, "descending") == 0) - systray.sort = -1; + systray.sort = SYSTRAY_SORT_DESCENDING; else if (strcmp(value, "ascending") == 0) - systray.sort = 1; + systray.sort = SYSTRAY_SORT_ASCENDING; else if (strcmp(value, "left2right") == 0) - systray.sort = 2; + systray.sort = SYSTRAY_SORT_LEFT2RIGHT; else if (strcmp(value, "right2left") == 0) - systray.sort = 3; + systray.sort = SYSTRAY_SORT_RIGHT2LEFT; } else if (strcmp(key, "systray_icon_size") == 0) { systray_max_icon_size = atoi(value);
M src/systray/systraybar.csrc/systray/systraybar.c

@@ -52,7 +52,7 @@ int refresh_systray;

int systray_enabled; int systray_max_icon_size; int systray_monitor; - +int chrono; // background pixmap if we render ourselves the icons static Pixmap render_background;

@@ -61,8 +61,9 @@ void default_systray()

{ memset(&systray, 0, sizeof(Systraybar)); render_background = 0; + chrono = 0; systray.alpha = 100; - systray.sort = 3; + systray.sort = SYSTRAY_SORT_LEFT2RIGHT; systray.area._draw_foreground = draw_systray; systray.area._on_change_layout = on_change_systray; systray.area.size_mode = SIZE_BY_CONTENT;

@@ -345,24 +346,33 @@ return 1;

if (!traywin_a->empty && traywin_b->empty) return -1; - if (systray.sort < 2) - return 0; + if (systray.sort == SYSTRAY_SORT_ASCENDING || + systray.sort == SYSTRAY_SORT_DESCENDING) { + XTextProperty name_a, name_b; - XTextProperty name_a, name_b; + if (XGetWMName(server.dsp, traywin_a->tray_id, &name_a) == 0) { + return -1; + } + else if (XGetWMName(server.dsp, traywin_b->tray_id, &name_b) == 0) { + XFree(name_a.value); + return 1; + } + else { + gint retval = g_ascii_strncasecmp((char*)name_a.value, (char*)name_b.value, -1) * + (systray.sort == SYSTRAY_SORT_ASCENDING ? 1 : -1); + XFree(name_a.value); + XFree(name_b.value); + return retval; + } + } - if(XGetWMName(server.dsp, traywin_a->tray_id, &name_a) == 0) { - return -1; + if (systray.sort == SYSTRAY_SORT_LEFT2RIGHT || + systray.sort == SYSTRAY_SORT_RIGHT2LEFT) { + return (traywin_a->chrono - traywin_b->chrono) * + (systray.sort == SYSTRAY_SORT_LEFT2RIGHT ? 1 : -1); } - else if(XGetWMName(server.dsp, traywin_b->tray_id, &name_b) == 0) { - XFree(name_a.value); - return 1; - } - else { - gint retval = g_ascii_strncasecmp((char*)name_a.value, (char*)name_b.value, -1) * systray.sort; - XFree(name_a.value); - XFree(name_b.value); - return retval; - } + + return 0; }

@@ -489,11 +499,13 @@ traywin->depth = attr.depth;

traywin->damage = 0; traywin->empty = 0; traywin->pid = pid; + traywin->chrono = chrono; + chrono++; if (systray.area.on_screen == 0) show(&systray.area); - if (systray.sort == 3) + if (systray.sort == SYSTRAY_SORT_RIGHT2LEFT) systray.list_icons = g_slist_prepend(systray.list_icons, traywin); else systray.list_icons = g_slist_append(systray.list_icons, traywin);
M src/systray/systraybar.hsrc/systray/systraybar.h

@@ -20,6 +20,7 @@ #define XEMBED_EMBEDDED_NOTIFY 0

// Flags for _XEMBED_INFO #define XEMBED_MAPPED (1 << 0) +enum { SYSTRAY_SORT_ASCENDING, SYSTRAY_SORT_DESCENDING, SYSTRAY_SORT_LEFT2RIGHT, SYSTRAY_SORT_RIGHT2LEFT }; typedef struct { // always start with area

@@ -45,6 +46,7 @@ Damage damage;

timeout* render_timeout; int empty; int pid; + int chrono; } TrayWindow;