]> git.sur5r.net Git - i3/i3/blobdiff - src/floating.c
Bugfix: use the global root variable, don’t get the first one (Thanks quaec)
[i3/i3] / src / floating.c
index 85b2c0ae18b4bf4fffbcca3bc730a623fa2e0578..c912dc713cdd53f4d2c47882c9242cda852c0a7f 100644 (file)
@@ -68,7 +68,7 @@ void floating_enable(Con *con, bool automatic) {
     TAILQ_REMOVE(&(con->parent->nodes_head), con, nodes);
     TAILQ_REMOVE(&(con->parent->focus_head), con, focused);
 
-    con_fix_percent(con->parent, WINDOW_REMOVE);
+    con_fix_percent(con->parent);
 
     /* 2: create a new container to render the decoration on, add
      * it as a floating window to the workspace */
@@ -102,6 +102,7 @@ void floating_enable(Con *con, bool automatic) {
 
     /* 3: attach the child to the new parent container */
     con->parent = nc;
+    con->percent = 1.0;
     con->floating = FLOATING_USER_ON;
 
     /* Some clients (like GIMP’s color picker window) get mapped
@@ -148,14 +149,23 @@ void floating_disable(Con *con, bool automatic) {
     TAILQ_REMOVE(&(con->parent->parent->focus_head), con->parent, focused);
     tree_close(con->parent, false, false);
 
-    /* 3: re-attach to previous parent */
-    con->parent = con_get_workspace(con);
+    /* 3: re-attach to the parent of the currently focused con on the workspace
+     * this floating con was on */
+    Con *focused = con_descend_focused(con_get_workspace(con));
+    con->parent = focused->parent;
+
+    /* XXX: We adjust the percentage value to start with a fair value. Floating
+     * cons always have 1.0 as percent which doesn’t work so well when
+     * re-inserting (the formerly floating con would get 50% of the target
+     * con). */
+    con->percent = (1.0 / con_num_children(con->parent));
+
     TAILQ_INSERT_TAIL(&(con->parent->nodes_head), con, nodes);
     TAILQ_INSERT_TAIL(&(con->parent->focus_head), con, focused);
 
     con->floating = FLOATING_USER_OFF;
 
-    con_fix_percent(con->parent, WINDOW_ADD);
+    con_fix_percent(con->parent);
     // TODO: don’t influence focus handling when Con was not focused before.
     con_focus(con);
 }
@@ -315,7 +325,6 @@ void floating_resize_window(Con *con, bool proportional,
 void drag_pointer(Con *con, xcb_button_press_event_t *event, xcb_window_t
                 confine_to, border_t border, callback_t callback, void *extra)
 {
-    xcb_window_t root = xcb_setup_roots_iterator(xcb_get_setup(conn)).data->root;
     uint32_t new_x, new_y;
     Rect old_rect;
     if (con != NULL)