commit a4aac68e8fec82673680ff29ce0dfb0dde1a25e0
parent 45d42ff15d91da3e25f3e1f7a4bd0360af6e0f70
Author: Kebigon <git@kebigon.xyz>
Date: Sat, 14 Aug 2021 16:20:37 +0900
Create clients for existing root's children after setting up the monitors, avoid having a NULL monitor on clients created from pre-existing root's children
Diffstat:
3 files changed, 23 insertions(+), 21 deletions(-)
diff --git a/client.c b/client.c
@@ -47,6 +47,26 @@ static inline uint16_t uint16_in_range(uint16_t value, uint16_t min, uint16_t ma
return value;
}
+void setup_clients()
+{
+ // Retrieve the children of the root window
+ xcb_query_tree_reply_t *reply = xcb_query_tree_reply(c, xcb_query_tree(c, screen->root), 0);
+ if (NULL == reply)
+ {
+ LOG_ERROR("Unable to retrieve the root window's children");
+ exit(-1);
+ }
+
+ int len = xcb_query_tree_children_length(reply);
+ xcb_window_t *children = xcb_query_tree_children(reply);
+
+ // Create the corresponding clients
+ for (int i = 0; i != len; i++)
+ client_create(children[i]);
+
+ free(reply);
+}
+
// Add a client to the current workspace list
void client_add(struct client *client)
{
diff --git a/client.h b/client.h
@@ -31,6 +31,8 @@ struct client
struct monitor *monitor;
};
+void setup_clients();
+
void client_grab_buttons(struct client *, bool);
void client_kill(const union Arg *);
void client_create(xcb_window_t);
diff --git a/kbgwm.c b/kbgwm.c
@@ -226,26 +226,6 @@ void setup_keyboard()
free(reply);
}
-void setup_screen()
-{
- // Retrieve the children of the root window
- xcb_query_tree_reply_t *reply = xcb_query_tree_reply(c, xcb_query_tree(c, screen->root), 0);
- if (NULL == reply)
- {
- LOG_ERROR("Unable to retrieve the root window's children");
- exit(-1);
- }
-
- int len = xcb_query_tree_children_length(reply);
- xcb_window_t *children = xcb_query_tree_children(reply);
-
- // Create the corresponding clients
- for (int i = 0; i != len; i++)
- client_create(children[i]);
-
- free(reply);
-}
-
/*
* Workspaces
*/
@@ -378,8 +358,8 @@ int main(void)
wm_delete_window = xcb_get_atom(WM_DELETE_WINDOW);
setup_keyboard();
- setup_screen();
setup_monitors();
+ setup_clients();
setup_events();
// Event loop