thoughts on the windowlist

Zach Carter linux at zachcarter.com
Fri Mar 16 00:38:15 CET 2007


Hi folks,

I just started to use xfce a few weeks ago, and I have to say, I'm
impressed.  Thank you all for creating this excellent desktop.  After
many years, I finally found something that could take the place of fvwm.

I do have a couple of thoughts about the windowlist code that I'd like
to bounce off the list.   I am a heavy multitasker, with lots of
workspaces, and lots of windows open, many of them sticky.   All this
means I end up with a *huge* windowlist.   I've made a couple of
modifications to the xfdesktop windowlist.c code to make it a little
more compact.   Basically, I changed three things: it only prints
sticky windows once (for the active workspace), it strips out the
code that prints the workspace names, and it ignores empty workspaces.

Does this arrangement appeal to anyone else?   Enough to make it into a
"compact windowlist" setting everyone can use?  Is there a better way to achieve a
streamlined windowlist?

-Zach

Patch #1, tells the windowlist to only list sticky windows once:

--- a/src/windowlist.c
+++ b/src/windowlist.c
@@ -252,13 +252,17 @@ windowlist_create(GdkScreen *gscreen)
              if((netk_window_get_workspace(netk_window) != netk_workspace
                          && !netk_window_is_sticky(netk_window))
                      || netk_window_is_skip_pager(netk_window)
-                    || netk_window_is_skip_tasklist(netk_window))
+                    || netk_window_is_skip_tasklist(netk_window)
+                    || (netk_window_is_sticky(netk_window)
+                        && (netk_workspace != active_workspace)))
              {
                  /* the window isn't on the current WS AND isn't sticky,
                   * OR,
                   * the window is set to skip the pager,
                   * OR,
                   * the window is set to skip the tasklist
+                 * OR,
+                 * the window is sticky, and we aren't on the current WS
                   */
                  continue;
              }

Patch #2, does the same thing as patch #1, strips out the code that prints the workspace titles, and 
doesn't print a seperator for empty workspaces:

--- a/src/windowlist.c
+++ b/src/windowlist.c
@@ -197,6 +197,7 @@ windowlist_create(GdkScreen *gscreen)
      GList *windows, *l;
      NetkWindow *netk_window;
      gint w, h;
+    gint is_empty_workspace;
      PangoFontDescription *italic_font_desc = pango_font_description_from_string("italic")

      g_return_val_if_fail(GDK_IS_SCREEN(gscreen), NULL);
@@ -215,50 +216,26 @@ windowlist_create(GdkScreen *gscreen)
          netk_workspace = netk_screen_get_workspace(netk_screen, i);
          ws_name = netk_workspace_get_name(netk_workspace);

-        if(netk_workspace == active_workspace) {
-            if(!ws_name || atoi(ws_name) == i+1)
-                ws_label = g_strdup_printf(_("<b>Workspace %d</b>"), i+1);
-            else {
-                gchar *ws_name_esc = g_markup_escape_text(ws_name, strlen(ws_name));
-                ws_label = g_strdup_printf("<b>%s</b>", ws_name_esc);
-                g_free(ws_name_esc);
-            }
-        } else {
-            if(!ws_name || atoi(ws_name) == i+1)
-                ws_label = g_strdup_printf(_("<i>Workspace %d</i>"), i+1);
-            else {
-                gchar *ws_name_esc = g_markup_escape_text(ws_name, strlen(ws_name));
-                ws_label = g_strdup_printf("<i>%s</i>", ws_name_esc);
-                g_free(ws_name_esc);
-            }
-        }
-        mi = gtk_menu_item_new_with_label(ws_label);
-        g_free(ws_label);
-        label = gtk_bin_get_child(GTK_BIN(mi));
-        gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
-        gtk_widget_show(mi);
-        gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi);
-        g_signal_connect_swapped(G_OBJECT(mi), "activate",
-                G_CALLBACK(netk_workspace_activate), netk_workspace);
-
-        mi = gtk_separator_menu_item_new();
-        gtk_widget_show(mi);
-        gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi);
-
          windows = netk_screen_get_windows_stacked(netk_screen);
+        is_empty_workspace = 0;
          for(l = windows; l; l = l->next) {
+
              netk_window = l->data;

              if((netk_window_get_workspace(netk_window) != netk_workspace
                          && !netk_window_is_sticky(netk_window))
                      || netk_window_is_skip_pager(netk_window)
-                    || netk_window_is_skip_tasklist(netk_window))
+                    || netk_window_is_skip_tasklist(netk_window)
+                    || (netk_window_is_sticky(netk_window)
+                              && (netk_workspace != active_workspace)))
              {
                  /* the window isn't on the current WS AND isn't sticky,
                   * OR,
                   * the window is set to skip the pager,
                   * OR,
                   * the window is set to skip the tasklist
+                 * OR,
+                 * the window is sticky, and we aren't in the active WS
                   */
                  continue;
              }
@@ -266,6 +243,7 @@ windowlist_create(GdkScreen *gscreen)
              mi = menu_item_from_netk_window(netk_window, w, h);
              if(!mi)
                  continue;
+            is_empty_workspace = 1;
              if(netk_workspace != active_workspace) {
                  GtkWidget *lbl = gtk_bin_get_child(GTK_BIN(mi));
                  gtk_widget_modify_fg(lbl, GTK_STATE_NORMAL,
@@ -282,9 +260,11 @@ windowlist_create(GdkScreen *gscreen)
                      G_CALLBACK(mi_destroyed_cb), netk_window);
          }

-        mi = gtk_separator_menu_item_new();
-        gtk_widget_show(mi);
-        gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi);
+        if (is_empty_workspace) {
+            mi = gtk_separator_menu_item_new();
+            gtk_widget_show(mi);
+            gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi);
+        }
      }

      pango_font_description_free(italic_font_desc);





More information about the Xfce mailing list