]> git.sur5r.net Git - i3/i3/commitdiff
Merge branch 'master' into next
authorMichael Stapelberg <michael@stapelberg.de>
Thu, 22 Sep 2011 19:11:44 +0000 (20:11 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Thu, 22 Sep 2011 19:11:44 +0000 (20:11 +0100)
include/tree.h
src/cmdparse.y
src/con.c
src/floating.c
src/handlers.c
src/randr.c
src/tree.c
src/workspace.c

index b9bf7f54ae0ce9baeee18803a69bd859f0becb36..b483434fcdaad90891cbdf09d8fd5a4f8f34ade7 100644 (file)
@@ -70,8 +70,15 @@ void tree_next(char way, orientation_t orientation);
  * Returns true if the container was killed or false if just WM_DELETE was sent
  * and the window is expected to kill itself.
  *
+ * The dont_kill_parent flag is specified when the function calls itself
+ * recursively while deleting a containers children.
+ *
+ * The force_set_focus flag is specified in the case of killing a floating
+ * window: tree_close() will be invoked for the CT_FLOATINGCON (the parent
+ * container) and focus should be set there.
+ *
  */
-bool tree_close(Con *con, kill_window_t kill_window, bool dont_kill_parent);
+bool tree_close(Con *con, kill_window_t kill_window, bool dont_kill_parent, bool force_set_focus);
 
 /**
  * Loads tree from ~/.i3/_restart.json (used for in-place restarts).
index 0a99c224d5b64c6fe19187d6dd8e18e92b51daec..04e8b3ca3f4cb0a8f66337a2132b5e2ceb90223f 100644 (file)
@@ -544,7 +544,7 @@ kill:
         else {
             TAILQ_FOREACH(current, &owindows, owindows) {
                 printf("matching: %p / %s\n", current->con, current->con->name);
-                tree_close(current->con, $2, false);
+                tree_close(current->con, $2, false, false);
             }
         }
 
index 148f782277fc40f18c180ada099f9419c7c69fbc..8fbedd3d608561e9346942184335256a65d2a0c1 100644 (file)
--- a/src/con.c
+++ b/src/con.c
@@ -1021,7 +1021,7 @@ static void con_on_remove_child(Con *con) {
     int children = con_num_children(con);
     if (children == 0) {
         DLOG("Container empty, closing\n");
-        tree_close(con, DONT_KILL_WINDOW, false);
+        tree_close(con, DONT_KILL_WINDOW, false, false);
         return;
     }
 }
index e225b8a6843820793e8976fbe37e13d3c13bd22f..e43f4703fa4d8ad7876f7500880bd90e26e271f1 100644 (file)
@@ -91,7 +91,7 @@ void floating_enable(Con *con, bool automatic) {
     /* check if the parent container is empty and close it if so */
     if ((con->parent->type == CT_CON || con->parent->type == CT_FLOATING_CON) && con_num_children(con->parent) == 0) {
         DLOG("Old container empty after setting this child to floating, closing\n");
-        tree_close(con->parent, DONT_KILL_WINDOW, false);
+        tree_close(con->parent, DONT_KILL_WINDOW, false, false);
     }
 
     char *name;
@@ -216,7 +216,7 @@ void floating_disable(Con *con, bool automatic) {
     /* 2: kill parent container */
     TAILQ_REMOVE(&(con->parent->parent->floating_head), con->parent, floating_windows);
     TAILQ_REMOVE(&(con->parent->parent->focus_head), con->parent, focused);
-    tree_close(con->parent, DONT_KILL_WINDOW, false);
+    tree_close(con->parent, DONT_KILL_WINDOW, false, false);
 
     /* 3: re-attach to the parent of the currently focused con on the workspace
      * this floating con was on */
index 36cf039fdc3bcb600ee7e682ae152f92471c4bfa..267159ecf515a7bb0a59b52b388066df1a96e1c7 100644 (file)
@@ -457,7 +457,7 @@ static int handle_unmap_notify_event(xcb_unmap_notify_event_t *event) {
         return 1;
     }
 
-    tree_close(con, DONT_KILL_WINDOW, false);
+    tree_close(con, DONT_KILL_WINDOW, false, false);
     tree_render();
     x_push_changes(croot);
     return 1;
index dd30925b9301c654132105bda8a23f325e452203..2b8757e5c25dc674647df2728d5f0fb1b1c1f352 100644 (file)
@@ -791,7 +791,7 @@ void randr_query_outputs() {
                 }
 
                 DLOG("destroying disappearing con %p\n", output->con);
-                tree_close(output->con, DONT_KILL_WINDOW, true);
+                tree_close(output->con, DONT_KILL_WINDOW, true, false);
                 DLOG("Done. Should be fine now\n");
                 output->con = NULL;
             }
index e688030f77281f9289c384270f406f0ff81e41c4..4baba58eed118118a85d99818c901ac6c603942d 100644 (file)
@@ -114,8 +114,15 @@ static bool _is_con_mapped(Con *con) {
  * Returns true if the container was killed or false if just WM_DELETE was sent
  * and the window is expected to kill itself.
  *
+ * The dont_kill_parent flag is specified when the function calls itself
+ * recursively while deleting a containers children.
+ *
+ * The force_set_focus flag is specified in the case of killing a floating
+ * window: tree_close() will be invoked for the CT_FLOATINGCON (the parent
+ * container) and focus should be set there.
+ *
  */
-bool tree_close(Con *con, kill_window_t kill_window, bool dont_kill_parent) {
+bool tree_close(Con *con, kill_window_t kill_window, bool dont_kill_parent, bool force_set_focus) {
     bool was_mapped = con->mapped;
     Con *parent = con->parent;
 
@@ -138,7 +145,7 @@ bool tree_close(Con *con, kill_window_t kill_window, bool dont_kill_parent) {
     for (child = TAILQ_FIRST(&(con->nodes_head)); child; ) {
         nextchild = TAILQ_NEXT(child, nodes);
         DLOG("killing child=%p\n", child);
-        if (!tree_close(child, kill_window, true))
+        if (!tree_close(child, kill_window, true, false))
             abort_kill = true;
         child = nextchild;
     }
@@ -191,7 +198,7 @@ bool tree_close(Con *con, kill_window_t kill_window, bool dont_kill_parent) {
     if (con_is_floating(con)) {
         Con *ws = con_get_workspace(con);
         DLOG("Container was floating, killing floating container\n");
-        tree_close(parent, DONT_KILL_WINDOW, false);
+        tree_close(parent, DONT_KILL_WINDOW, false, (con == focused));
         DLOG("parent container killed\n");
         if (con == focused) {
             DLOG("This is the focused container, i need to find another one to focus. I start looking at ws = %p\n", ws);
@@ -224,7 +231,7 @@ bool tree_close(Con *con, kill_window_t kill_window, bool dont_kill_parent) {
                 /* Instead of focusing the dockarea, we need to restore focus to the workspace */
                 con_focus(con_descend_focused(output_get_content(next->parent)));
             } else {
-                if (con != focused)
+                if (!force_set_focus && con != focused)
                     DLOG("not changing focus, the container was not focused before\n");
                 else con_focus(next);
             }
@@ -259,7 +266,7 @@ void tree_close_con(kill_window_t kill_window) {
     assert(focused->type != CT_ROOT);
 
     /* Kill con */
-    tree_close(focused, kill_window, false);
+    tree_close(focused, kill_window, false, false);
 }
 
 /*
@@ -572,7 +579,7 @@ void tree_flatten(Con *con) {
 
     /* 4: close the redundant cons */
     DLOG("closing redundant cons\n");
-    tree_close(con, DONT_KILL_WINDOW, true);
+    tree_close(con, DONT_KILL_WINDOW, true, false);
 
     /* Well, we got to abort the recursion here because we destroyed the
      * container. However, if tree_flatten() is called sufficiently often,
index 27899a3781656ce61b301b217704aef3f11c2f8e..325644598453e98b337f756ccd988fd21dbb3223 100644 (file)
@@ -211,7 +211,7 @@ void workspace_show(const char *num) {
         /* check if this workspace is currently visible */
         if (!workspace_is_visible(old)) {
             LOG("Closing old workspace (%p / %s), it is empty\n", old, old->name);
-            tree_close(old, DONT_KILL_WINDOW, false);
+            tree_close(old, DONT_KILL_WINDOW, false, false);
             ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"empty\"}");
             changed_num_workspaces = true;
         }