3 #include <xcb/xcb_ewmh.h>
12 ewmh = malloc(sizeof(xcb_ewmh_connection_t));
13 if (xcb_ewmh_init_atoms_replies(ewmh, xcb_ewmh_init_atoms(dpy, ewmh), NULL) == 0)
14 err("Can't initialize EWMH atoms.\n");
17 void ewmh_update_wm_name(void)
20 xcb_ewmh_set_wm_name(ewmh, root, strlen(wm_name), wm_name);
23 void ewmh_update_active_window(void)
25 xcb_window_t win = (mon->desk->focus == NULL ? XCB_NONE : mon->desk->focus->client->window);
26 xcb_ewmh_set_active_window(ewmh, default_screen, win);
29 void ewmh_update_number_of_desktops(void)
31 xcb_ewmh_set_number_of_desktops(ewmh, default_screen, num_desktops);
34 uint32_t ewmh_get_desktop_index(desktop_t *d)
37 for (monitor_t *m = mon_head; m != NULL; m = m->next)
38 for (desktop_t *cd = m->desk_head; cd != NULL; cd = cd->next, i++)
45 bool ewmh_locate_desktop(uint32_t i, desktop_location_t *loc)
47 for (monitor_t *m = mon_head; m != NULL; m = m->next)
48 for (desktop_t *d = m->desk_head; d != NULL; d = d->next, i--)
58 void ewmh_update_current_desktop(void)
60 uint32_t i = ewmh_get_desktop_index(mon->desk);
61 xcb_ewmh_set_current_desktop(ewmh, default_screen, i);
64 void ewmh_set_wm_desktop(node_t *n, desktop_t *d)
66 uint32_t i = ewmh_get_desktop_index(d);
67 xcb_ewmh_set_wm_desktop(ewmh, n->client->window, i);
70 void ewmh_update_desktop_names(void)
76 for (monitor_t *m = mon_head; m != NULL; m = m->next)
77 for (desktop_t *d = m->desk_head; d != NULL && i < num_desktops; d = d->next) {
78 for (unsigned int j = 0; j < strlen(d->name); j++)
79 names[pos + j] = d->name[j];
80 pos += strlen(d->name);
85 if (i != num_desktops)
89 xcb_ewmh_set_desktop_names(ewmh, default_screen, pos, names);
92 void ewmh_update_client_list(void)
94 if (num_clients == 0) {
95 xcb_ewmh_set_client_list(ewmh, default_screen, 0, NULL);
99 xcb_window_t wins[num_clients];
102 for (monitor_t *m = mon_head; m != NULL; m = m->next)
103 for (desktop_t *d = m->desk_head; d != NULL; d = d->next)
104 for (node_t *n = first_extrema(d->root); n != NULL; n = next_leaf(n, d->root))
105 wins[i++] = n->client->window;
107 if (i != num_clients)
110 xcb_ewmh_set_client_list(ewmh, default_screen, num_clients, wins);
111 xcb_ewmh_set_client_list_stacking(ewmh, default_screen, num_clients, wins);