[openbox] Client list wish

Jim Rees rees at umich.edu
Thu Jul 2 18:15:20 EDT 2015


I do wish the client list menu was more configurable. The MRU order doesn't
seem very useful. Here's my patch, which puts them in alphabetical
order. It's not what you asked for but might help someone.

>From a63468a671892468dd8bc5116bce7fcac676aacb Mon Sep 17 00:00:00 2001
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 | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/openbox/client_list_combined_menu.c b/openbox/client_list_combined_menu.c
index c26b6fa..3c51f14 100644
--- a/openbox/client_list_combined_menu.c
+++ b/openbox/client_list_combined_menu.c
@@ -42,11 +42,18 @@ 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;
     ObMenuEntry *e;
-    GList *it;
+    GList *it, *sorted_it;
     guint desktop;
 
     menu_clear_entries(menu);
@@ -55,8 +62,10 @@ static gboolean self_update(ObMenuFrame *frame, gpointer data)
         gboolean empty = TRUE;
         gboolean onlyiconic = TRUE;
 
+        sorted_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 = sorted_it; it; it = g_list_next(it)) {
             ObClient *c = it->data;
             if (focus_valid_target(c, desktop,
                                    TRUE, TRUE,
@@ -83,6 +92,7 @@ static gboolean self_update(ObMenuFrame *frame, gpointer data)
                 e->data.normal.data = c;
             }
         }
+        g_list_free(sorted_it);
 
         if (empty || onlyiconic) {
             /* no entries or only iconified windows, so add a
-- 
2.2.2


More information about the openbox mailing list