From: Thierry Lorthiois Date: Sat, 29 Aug 2009 22:09:29 +0000 (+0000) Subject: fixed issue 130 by maato X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=9ad50cc90314fb960c8eea1d41f912f6d9e402fd;p=chaz%2Ftint2 fixed issue 130 by maato --- diff --git a/ChangeLog b/ChangeLog index f78eedb..235dfcd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-08-30 +- fixed issue 130 by maato + ordered systray icon with config "systray_sort = asc/desc" + 2009-08-29 - fixed issue 134 diff --git a/src/config.c b/src/config.c index 10fd1aa..a7d11a2 100644 --- a/src/config.c +++ b/src/config.c @@ -84,6 +84,7 @@ void init_config() list_back = g_slist_append(0, calloc(1, sizeof(Area))); panel_config = calloc(1, sizeof(Panel)); + systray.sort = 1; // window manager's menu default value == false wm_menu = 0; max_tick_urgent = 7; @@ -557,6 +558,12 @@ void add_entry (char *key, char *value) memcpy(&systray.area.pix.back, &a->pix.back, sizeof(Color)); memcpy(&systray.area.pix.border, &a->pix.border, sizeof(Border)); } + else if (strcmp(key, "systray_sort") == 0) { + if (strcmp(value, "desc") == 0) + systray.sort = -1; + else + systray.sort = 1; + } /* Mouse actions */ else if (strcmp (key, "mouse_middle") == 0) diff --git a/src/systray/systraybar.c b/src/systray/systraybar.c index 069a3fc..c135077 100644 --- a/src/systray/systraybar.c +++ b/src/systray/systraybar.c @@ -227,6 +227,28 @@ int window_error_handler(Display *d, XErrorEvent *e) } +static gint compare_traywindows(gconstpointer a, gconstpointer b) +{ + const TrayWindow * traywin_a = (TrayWindow*)a; + const TrayWindow * traywin_b = (TrayWindow*)b; + XTextProperty name_a, name_b; + + if(XGetWMName(server.dsp, traywin_a->id, &name_a) == 0) { + return -1; + } + else if(XGetWMName(server.dsp, traywin_b->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; + } +} + + gboolean add_icon(Window id) { TrayWindow *traywin; @@ -276,7 +298,8 @@ gboolean add_icon(Window id) traywin = g_new0(TrayWindow, 1); traywin->id = id; - systray.list_icons = g_slist_prepend(systray.list_icons, traywin); +// systray.list_icons = g_slist_prepend(systray.list_icons, traywin); + systray.list_icons = g_slist_insert_sorted(systray.list_icons, traywin, compare_traywindows); systray.area.resize = 1; systray.area.redraw = 1; //printf("add_icon id %lx, %d\n", id, g_slist_length(systray.list_icons)); diff --git a/src/systray/systraybar.h b/src/systray/systraybar.h index 03c0313..d9f43bb 100644 --- a/src/systray/systraybar.h +++ b/src/systray/systraybar.h @@ -24,6 +24,7 @@ typedef struct { Area area; GSList *list_icons; + int sort; } Systraybar;