Browse Source

add _NET_CLIENT_LIST support

Martin Duquesnoy 12 years ago
parent
commit
d015dc2904
3 changed files with 32 additions and 0 deletions
  1. 4 0
      src/client.c
  2. 27 0
      src/ewmh.c
  3. 1 0
      src/ewmh.h

+ 4 - 0
src/client.c

@@ -970,6 +970,8 @@ client_new(Window w, XWindowAttributes *wa, bool scan)
           ewmh_manage_window_type(c);
      }
 
+     ewmh_get_client_list();
+
      return c;
 }
 
@@ -1408,6 +1410,8 @@ client_remove(struct client *c)
      XSetErrorHandler(wmfs_error_handler);
 
      free(c);
+
+     ewmh_get_client_list();
 }
 
 void

+ 27 - 0
src/ewmh.c

@@ -111,6 +111,33 @@ ewmh_set_wm_state(Window w, int state)
                      W->net_atom[wm_state], 32, PropModeReplace, d, 2);
 }
 
+/*
+ * _NET_CLIENT_LIST
+ */
+void
+ewmh_get_client_list(void)
+{
+     Window *list;
+     struct client *c;
+     int win_n = 0;
+
+     SLIST_FOREACH(c, &W->h.client, next)
+          ++win_n;
+
+     list = xcalloc(win_n, sizeof(Window));
+
+     win_n = 0;
+     SLIST_FOREACH(c, &W->h.client, next)
+          list[win_n++] = c->win;
+
+     XChangeProperty(W->dpy, W->root, W->net_atom[net_client_list], XA_WINDOW, 32,
+                     PropModeReplace, (unsigned char *)list, win_n);
+
+     XFree(list);
+
+     return;
+}
+
 /*
  * Get xembed state
  */

+ 1 - 0
src/ewmh.h

@@ -118,6 +118,7 @@ ewmh_send_message(Window d, Window w, char *atom, long d0, long d1, long d2, lon
 
 void ewmh_init(void);
 void ewmh_set_wm_state(Window w, int state);
+void ewmh_get_client_list(void);
 long ewmh_get_xembed_state(Window win);
 void ewmh_update_wmfs_props(void);
 void ewmh_manage_state(long data[], struct client *c);