From a6051a3146da4d99788905c0805890d78ab004da Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Thu, 8 Dec 2022 14:00:13 +0100 Subject: Added dpy_update_window_list() call and impl. --- schewm.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'schewm.c') diff --git a/schewm.c b/schewm.c index 8d19b60..350ed80 100644 --- a/schewm.c +++ b/schewm.c @@ -1432,6 +1432,25 @@ find_monitor(const struct Client *client) { return monitor; } +void +dpy_update_window_list(const struct ClientsMap *clients) { + xcb_window_t *windows = NULL; + size_t num_windows = 0; + if (clients->size != 0) { + windows = malloc(clients->size * sizeof(xcb_window_t)); + for (size_t i = 0; i < clients->table_size; i++) { + for (struct ClientList *list = clients->table[i]; + list != NULL; + list = list->next) { + windows[num_windows++] = list->client->id; + } + } + } + + xcb_ewmh_set_client_list(dpy.ewmh, dpy.screen_num, num_windows, windows); + free(windows); +} + void dpy_destroy() { if (dpy.ewmh) { @@ -1740,10 +1759,16 @@ wm_init() { wm.is_running = true; wm.focus = NULL; wm.clients = clients_map_new(128); + if (wm.clients == NULL) { + return false; + } wm.cur_workspace = 0; wm.num_workspaces = 10; wm.workspaces = calloc(wm.num_workspaces, sizeof(struct Workspace)); + if (wm.workspaces == NULL) { + return false; + } dpy_set_num_workspaces(); // Look into all existing windows and set them up @@ -1762,14 +1787,14 @@ wm_init() { * Unmap everything we grab initially because they may be * mapped currently, but belong to another workspace; this * way, we can map again only the correct windows at the - * set_workspace() call below. + * wm_set_workspace() call below. */ dpy_unmap_window(window); } } windows_query_reply_free(&reply); - // update_client_list(); + dpy_update_window_list(wm.clients); wm_set_workspace(wm.cur_workspace); // grab_keys(); dpy_grab_key(XCB_MOD_MASK_ANY, XK_q); -- cgit v1.2.3