[openbox] put client-list-combined-menu in alphabetical order

Jim Rees rees at umich.edu
Sat Jan 24 13:50:01 EST 2015


Here is a patch I have found useful. It puts the client list menu in
alphabetical order. To finish this, you would have to make it configurable,
and also do the non-combined menu.

From: Jim Rees <rees at umich.edu>
Date: Sat, 24 Jan 2015 13:39:18 -0500
Subject: [PATCH 6/6] put client-list-combined-menu in alphabetical order

Signed-off-by: Jim Rees <rees at umich.edu>
---
 openbox/client_list_combined_menu.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/openbox/client_list_combined_menu.c b/openbox/client_list_combined_menu.c
index c26b6fa..2a3e083 100644
--- a/openbox/client_list_combined_menu.c
+++ b/openbox/client_list_combined_menu.c
@@ -42,6 +42,13 @@ static void self_cleanup(ObMenu *menu, gpointer data)
     menu_clear_entries(menu);
 }
 
+static gint
+compfunc(gconstpointer a, gconstpointer b)
+{
+    ObClient *c1 = (ObClient *) a, *c2 = (ObClient *) b;
+    return strcmp(c1->title, c2->title);
+}
+
 static gboolean self_update(ObMenuFrame *frame, gpointer data)
 {
     ObMenu *menu = frame->menu;
@@ -55,8 +62,10 @@ static gboolean self_update(ObMenuFrame *frame, gpointer data)
         gboolean empty = TRUE;
         gboolean onlyiconic = TRUE;
 
+        it = g_list_sort(g_list_copy(focus_order), compfunc);
+
         menu_add_separator(menu, SEPARATOR, screen_desktop_names[desktop]);
-        for (it = focus_order; it; it = g_list_next(it)) {
+        for (; it; it = g_list_next(it)) {
             ObClient *c = it->data;
             if (focus_valid_target(c, desktop,
                                    TRUE, TRUE,
-- 
2.2.2


More information about the openbox mailing list