]> git.sur5r.net Git - i3/i3/blobdiff - src/con.c
Bugfix: don’t overwrite the original size of floating windows when changing border...
[i3/i3] / src / con.c
index 5a3c88d21ce0bd8dff731ff8e3df44c8a8a40f6e..14948cc6c2155eb40874f1b494cf0fd3b7540913 100644 (file)
--- a/src/con.c
+++ b/src/con.c
@@ -241,6 +241,17 @@ bool con_is_leaf(Con *con) {
     return TAILQ_EMPTY(&(con->nodes_head));
 }
 
+/*
+ * Returns true when this con is a leaf node with a managed X11 window (e.g.,
+ * excluding dock containers)
+ */
+bool con_has_managed_window(Con *con) {
+    return (con != NULL
+            && con->window != NULL
+            && con->window->id != XCB_WINDOW_NONE
+            && con_get_workspace(con) != NULL);
+}
+
 /**
  * Returns true if this node has regular or floating children.
  *
@@ -609,6 +620,9 @@ void con_toggle_fullscreen(Con *con, int fullscreen_mode) {
 
     DLOG("mode now: %d\n", con->fullscreen_mode);
 
+    /* Send an ipc window "fullscreen_mode" event */
+    ipc_send_window_event("fullscreen_mode", con);
+
     /* update _NET_WM_STATE if this container has a window */
     /* TODO: when a window is assigned to a container which is already
      * fullscreened, this state needs to be pushed to the client, too */
@@ -1076,8 +1090,13 @@ Rect con_border_style_rect(Con *con) {
     int border_width = con->current_border_width;
     DLOG("The border width for con is set to: %d\n", con->current_border_width);
     Rect result;
-    if (con->current_border_width < 0)
-        border_width = config.default_border_width;
+    if (con->current_border_width < 0) {
+        if (con_is_floating(con)) {
+            border_width = config.default_floating_border_width;
+        } else {
+            border_width = config.default_border_width;
+        }
+    }
     DLOG("Effective border width is set to: %d\n", border_width);
     /* Shortcut to avoid calling con_adjacent_borders() on dock containers. */
     int border_style = con_border_style(con);
@@ -1175,34 +1194,30 @@ void con_set_border_style(Con *con, int border_style, int border_width) {
 
     /* For floating containers, we want to keep the position/size of the
      * *window* itself. We first add the border pixels to con->rect to make
-     * con->rect represent the absolute position of the window. Then, we change
-     * the border and subtract the new border pixels. Afterwards, we update
-     * parent->rect to contain con. */
+     * con->rect represent the absolute position of the window (same for
+     * parent). Then, we change the border style and subtract the new border
+     * pixels. For the parent, we do the same also for the decoration. */
     DLOG("This is a floating container\n");
 
+    Con *parent = con->parent;
     Rect bsr = con_border_style_rect(con);
-    con->rect.x += bsr.x;
-    con->rect.y += bsr.y;
-    con->rect.width += bsr.width;
-    con->rect.height += bsr.height;
+    int deco_height = (con->border_style == BS_NORMAL ? render_deco_height() : 0);
+
+    con->rect = rect_add(con->rect, bsr);
+    parent->rect = rect_add(parent->rect, bsr);
+    parent->rect.y += deco_height;
+    parent->rect.height -= deco_height;
 
     /* Change the border style, get new border/decoration values. */
     con->border_style = border_style;
     con->current_border_width = border_width;
     bsr = con_border_style_rect(con);
-    int deco_height =
-        (con->border_style == BS_NORMAL ? render_deco_height() : 0);
-
-    con->rect.x -= bsr.x;
-    con->rect.y -= bsr.y;
-    con->rect.width -= bsr.width;
-    con->rect.height -= bsr.height;
+    deco_height = (con->border_style == BS_NORMAL ? render_deco_height() : 0);
 
-    Con *parent = con->parent;
-    parent->rect.x = con->rect.x;
-    parent->rect.y = con->rect.y - deco_height;
-    parent->rect.width = con->rect.width;
-    parent->rect.height = con->rect.height + deco_height;
+    con->rect = rect_sub(con->rect, bsr);
+    parent->rect = rect_sub(parent->rect, bsr);
+    parent->rect.y -= deco_height;
+    parent->rect.height += deco_height;
 }
 
 /*