]> git.sur5r.net Git - i3/i3/commitdiff
Add parameter to reparent windows instead of killing them when closing a container
authorMichael Stapelberg <michael@stapelberg.de>
Fri, 14 May 2010 22:16:59 +0000 (00:16 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Fri, 14 May 2010 22:16:59 +0000 (00:16 +0200)
Necessary because when windows are unmapped, they are not necessary to
be killed (an application can unmap it temporarily).

include/tree.h
src/cmdparse.y
src/floating.c
src/handlers.c
src/tree.c
src/workspace.c

index 029bbe346b931cfc8813c73ab9321250d787f2c6..fd393d8b08a0622aafb16972f0157a2f7013c56b 100644 (file)
@@ -21,7 +21,7 @@ void tree_render();
 void tree_close_con();
 void tree_next(char way, orientation_t orientation);
 void tree_move(char way, orientation_t orientation);
-void tree_close(Con *con);
+void tree_close(Con *con, bool kill_window);
 bool tree_restore();
 
 #endif
index 47faa7f7d93b9e96cda3ffd12c6fb2d7d392d625..31d7535b3e4171f32eb6116098aabae63298b109 100644 (file)
@@ -314,11 +314,11 @@ kill:
         printf("killing!\n");
         /* check if the match is empty, not if the result is empty */
         if (match_is_empty(&current_match))
-            tree_close(focused);
+            tree_close(focused, true);
         else {
             TAILQ_FOREACH(current, &owindows, owindows) {
                 printf("matching: %p / %s\n", current->con, current->con->name);
-                tree_close(current->con);
+                tree_close(current->con, true);
             }
         }
 
index cd387ba8a1b4bdf4a49d37e4794691deda56ac9f..2afe1b8218876bd9be0b12278805fe8c2f8246b9 100644 (file)
@@ -37,7 +37,7 @@ void toggle_floating_mode(Con *con, bool automatic) {
 
                 /* 2: kill parent container */
                 TAILQ_REMOVE(&(con->parent->parent->floating_head), con->parent, floating_windows);
-                tree_close(con->parent);
+                tree_close(con->parent, false);
 
                 /* 3: re-attach to previous parent */
                 con->parent = con->old_parent;
index bca297ee8b9879faa08c872f44b5e798859df6cd..e351aea01e5a4e17204554087db3af8164124bc0 100644 (file)
@@ -469,7 +469,7 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_noti
         return 1;
     }
 
-    tree_close(con);
+    tree_close(con, false);
     tree_render();
     x_push_changes(croot);
     return 1;
index 8a3bdf2d789f701b418cbe8b02ea389fcd602050..d8fc9f4a240d83f307bce34e6c04a846a618c887 100644 (file)
@@ -108,7 +108,7 @@ Con *tree_open_con(Con *con) {
  * Closes the given container including all children
  *
  */
-void tree_close(Con *con) {
+void tree_close(Con *con, bool kill_window) {
     /* TODO: check floating clients and adjust old_parent if necessary */
 
     /* Get the container which is next focused */
@@ -129,7 +129,19 @@ void tree_close(Con *con) {
      * in their parent’s nodes_head */
     while (!TAILQ_EMPTY(&(con->nodes_head))) {
         child = TAILQ_FIRST(&(con->nodes_head));
-        tree_close(child);
+        tree_close(child, kill_window);
+    }
+
+    if (con->window != NULL) {
+        if (kill_window)
+            x_window_kill(con->window->id);
+        else {
+            /* un-parent the window */
+            xcb_reparent_window(conn, con->window->id, root, 0, 0);
+            /* TODO: client_unmap to set state to withdrawn */
+
+        }
+        free(con->window);
     }
 
     /* kill the X11 part of this container */
@@ -138,10 +150,6 @@ void tree_close(Con *con) {
     con_detach(con);
     con_fix_percent(con->parent, WINDOW_REMOVE);
 
-    if (con->window != NULL) {
-        x_window_kill(con->window->id);
-        free(con->window);
-    }
     free(con->name);
     TAILQ_REMOVE(&all_cons, con, all_cons);
     free(con);
@@ -158,7 +166,7 @@ void tree_close_con() {
     }
 
     /* Kill con */
-    tree_close(focused);
+    tree_close(focused, true);
 }
 
 /*
index 1829370cf542d697825783ef2cc5da362c9b3080..6404cff03e489271f218a6f066d4a92e653ba885 100644 (file)
@@ -117,7 +117,7 @@ void workspace_show(const char *num) {
 
     if (TAILQ_EMPTY(&(old->nodes_head))) {
         LOG("Closing old workspace (%p / %s), it is empty\n", old, old->name);
-        tree_close(old);
+        tree_close(old, false);
     }
 
     con_focus(next);