]> git.lizzy.rs Git - bspwm.git/blobdiff - ewmh.c
Reset stacking client list whenever appropriate
[bspwm.git] / ewmh.c
diff --git a/ewmh.c b/ewmh.c
index f4014b03c11a13cb8554c68a534b6aa248929605..d18ad385a26590a99fb6e6fbd25fd65e793ca273 100644 (file)
--- a/ewmh.c
+++ b/ewmh.c
@@ -70,29 +70,20 @@ void ewmh_set_wm_desktop(node_t *n, desktop_t *d)
 void ewmh_update_desktop_names(void)
 {
     char names[MAXLEN];
-    monitor_t *m = mon_head;
     unsigned int pos, i;
     pos = i = 0;
 
-    while (m != NULL) {
-        desktop_t *d = m->desk_head;
-
-        while (d != NULL && i < num_desktops) {
+    for (monitor_t *m = mon_head; m != NULL; m = m->next)
+        for (desktop_t *d = m->desk_head; d != NULL && i < num_desktops; d = d->next) {
             for (unsigned int j = 0; j < strlen(d->name); j++)
                 names[pos + j] = d->name[j];
             pos += strlen(d->name);
             names[pos] = '\0';
-            pos++;
-            d = d->next;
-            i++;
+            pos++, i++;
         }
 
-        m = m->next;
-    }
-
     if (i != num_desktops)
         return;
-
     pos--;
 
     xcb_ewmh_set_desktop_names(ewmh, default_screen, pos, names);
@@ -102,6 +93,7 @@ void ewmh_update_client_list(void)
 {
     if (num_clients == 0) {
         xcb_ewmh_set_client_list(ewmh, default_screen, 0, NULL);
+        xcb_ewmh_set_client_list_stacking(ewmh, default_screen, 0, NULL);
         return;
     }
 
@@ -110,11 +102,12 @@ void ewmh_update_client_list(void)
 
     for (monitor_t *m = mon_head; m != NULL; m = m->next)
         for (desktop_t *d = m->desk_head; d != NULL; d = d->next)
-            for (node_t *n = first_extrema(d->root); n != NULL; n = next_leaf(n))
+            for (node_t *n = first_extrema(d->root); n != NULL; n = next_leaf(n, d->root))
                 wins[i++] = n->client->window;
 
     if (i != num_clients)
         return;
 
     xcb_ewmh_set_client_list(ewmh, default_screen, num_clients, wins);
+    xcb_ewmh_set_client_list_stacking(ewmh, default_screen, num_clients, wins);
 }