]> git.lizzy.rs Git - bspwm.git/commitdiff
New message: 'adopt_orphans'
authorBastien Dejean <nihilhill@gmail.com>
Thu, 25 Oct 2012 19:02:04 +0000 (21:02 +0200)
committerBastien Dejean <nihilhill@gmail.com>
Thu, 25 Oct 2012 19:02:04 +0000 (21:02 +0200)
The adoption of orphans needs to occur after the definition of desktops
and rules in the *autostart*.

README.md
bspwm.1
bspwm.c
messages.c
window.c
window.h

index cb09fe41ab3d93cbae32d9817604f12d4e28a81a..122de2c84c937dd11a80429a92a0d0f7afb87820 100644 (file)
--- 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 5c5d7849435bbca3f7e6b6437049a43f241afb5b..de0aae64f6f37fadccfa122ba5393bb2d9807e6d 100644 (file)
--- 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 f8085a75807d3a6070806d9d03760753cfc05ee3..f52a75b8817bd998603924c528c5cb29ae496ed1 100644 (file)
--- 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) {
 
index ac218a299f17e20f2a189cfe3209f297980c7730..747fff23f16c188445b90417829d14c834c53666 100644 (file)
@@ -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();
index 89f6c5a3f5efc617100903d41383a3a2a9864f6c..5d2b0109fc3ba426ab59e0cdc0fc7f93fe181e25 100644 (file)
--- 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)
index f20d2de1772b46be5f866afdd3aa24dd5590d931..2a91cc79cb87913a74c1e75f7f452f875da62511 100644 (file)
--- 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 *);