fixed issue 130 by maato

git-svn-id: http://tint2.googlecode.com/svn/trunk@165 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
lorthiois@bbsoft.fr 2009-08-29 22:09:29 +00:00
parent f3260b67c5
commit c8d09ed731
4 changed files with 36 additions and 1 deletions

View file

@ -1,3 +1,7 @@
2009-08-30
- fixed issue 130 by maato
ordered systray icon with config "systray_sort = asc/desc"
2009-08-29 2009-08-29
- fixed issue 134 - fixed issue 134

View file

@ -84,6 +84,7 @@ void init_config()
list_back = g_slist_append(0, calloc(1, sizeof(Area))); list_back = g_slist_append(0, calloc(1, sizeof(Area)));
panel_config = calloc(1, sizeof(Panel)); panel_config = calloc(1, sizeof(Panel));
systray.sort = 1;
// window manager's menu default value == false // window manager's menu default value == false
wm_menu = 0; wm_menu = 0;
max_tick_urgent = 7; 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.back, &a->pix.back, sizeof(Color));
memcpy(&systray.area.pix.border, &a->pix.border, sizeof(Border)); 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 */ /* Mouse actions */
else if (strcmp (key, "mouse_middle") == 0) else if (strcmp (key, "mouse_middle") == 0)

View file

@ -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) gboolean add_icon(Window id)
{ {
TrayWindow *traywin; TrayWindow *traywin;
@ -276,7 +298,8 @@ gboolean add_icon(Window id)
traywin = g_new0(TrayWindow, 1); traywin = g_new0(TrayWindow, 1);
traywin->id = id; 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.resize = 1;
systray.area.redraw = 1; systray.area.redraw = 1;
//printf("add_icon id %lx, %d\n", id, g_slist_length(systray.list_icons)); //printf("add_icon id %lx, %d\n", id, g_slist_length(systray.list_icons));

View file

@ -24,6 +24,7 @@ typedef struct {
Area area; Area area;
GSList *list_icons; GSList *list_icons;
int sort;
} Systraybar; } Systraybar;