From: Bastien Dejean Date: Thu, 25 Oct 2012 19:02:04 +0000 (+0200) Subject: New message: 'adopt_orphans' X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=0061b7244571db533e8972303b3062e1d9b3cbe0;p=bspwm.git New message: 'adopt_orphans' The adoption of orphans needs to occur after the definition of desktops and rules in the *autostart*. --- diff --git a/README.md b/README.md index cb09fe4..122de2c 100644 --- a/README.md +++ b/README.md @@ -185,6 +185,9 @@ The following messages are handled: rule PATTERN floating Make a new rule that will float the windows whose class name or instance name equals PATTERN. + adopt_orphans + Manage all the unmanaged windows remaining from a previous session. + reload_autostart Reload the autostart file. diff --git a/bspwm.1 b/bspwm.1 index 5c5d784..de0aae6 100644 --- a/bspwm.1 +++ b/bspwm.1 @@ -214,6 +214,9 @@ Move all the fences toward the given corner. .BI rule " PATTERN floating " Make a new rule that will float the windows whose class name or instance name equals PATTERN. .TP +.BI adopt_orphans +Manage all the unmanaged windows remaining from a previous session. +.TP .BI reload_autostart Reload the autostart file. .TP diff --git a/bspwm.c b/bspwm.c index f8085a7..f52a75b 100644 --- a/bspwm.c +++ b/bspwm.c @@ -54,22 +54,6 @@ void ungrab_buttons(void) xcb_ungrab_button(dpy, XCB_BUTTON_INDEX_3, screen->root, button_modifier); } -void adopt_orphans(void) -{ - xcb_query_tree_reply_t *qtr = xcb_query_tree_reply(dpy, xcb_query_tree(dpy, screen->root), NULL); - if (qtr == NULL) - return; - int len = xcb_query_tree_children_length(qtr); - xcb_window_t *wins = xcb_query_tree_children(qtr); - for (int i = 0; i < len; i++) { - uint32_t d; - xcb_window_t win = wins[i]; - if (xcb_ewmh_get_wm_desktop_reply(ewmh, xcb_ewmh_get_wm_desktop(ewmh, win), &d, NULL) == 1) - manage_window(win); - } - free(qtr); -} - void setup(void) { ewmh_init(); @@ -191,7 +175,6 @@ int main(int argc, char *argv[]) run_autostart(); grab_buttons(); ewmh_update_wm_name(); - adopt_orphans(); while (running) { diff --git a/messages.c b/messages.c index ac218a2..747fff2 100644 --- a/messages.c +++ b/messages.c @@ -279,6 +279,8 @@ void process_message(char *msg, char *rsp) } if (mon->desk->layout == LAYOUT_TILED) return; + } else if (strcmp(cmd, "adopt_orphans") == 0) { + adopt_orphans(); } else if (strcmp(cmd, "reload") == 0) { load_settings(); run_autostart(); diff --git a/window.c b/window.c index 89f6c5a..5d2b010 100644 --- a/window.c +++ b/window.c @@ -121,6 +121,22 @@ void manage_window(xcb_window_t win) ewmh_update_client_list(); } +void adopt_orphans(void) +{ + xcb_query_tree_reply_t *qtr = xcb_query_tree_reply(dpy, xcb_query_tree(dpy, screen->root), NULL); + if (qtr == NULL) + return; + int len = xcb_query_tree_children_length(qtr); + xcb_window_t *wins = xcb_query_tree_children(qtr); + for (int i = 0; i < len; i++) { + uint32_t d; + xcb_window_t win = wins[i]; + if (xcb_ewmh_get_wm_desktop_reply(ewmh, xcb_ewmh_get_wm_desktop(ewmh, win), &d, NULL) == 1) + manage_window(win); + } + free(qtr); +} + void window_draw_border(node_t *n, bool focused_window, bool focused_monitor) { if (n == NULL) diff --git a/window.h b/window.h index f20d2de..2a91cc7 100644 --- a/window.h +++ b/window.h @@ -9,6 +9,7 @@ bool locate_window(xcb_window_t, window_location_t *); bool locate_desktop(char *, desktop_location_t *); void manage_window(xcb_window_t); +void adopt_orphans(void); void window_draw_border(node_t *, bool, bool); void window_close(node_t *); void window_kill(desktop_t *, node_t *);