]> git.sur5r.net Git - i3/i3/blobdiff - src/floating.c
Merge branch 'master' into next
[i3/i3] / src / floating.c
index 0bc5f6d65aac466814b08c62350c5c4d6fe18d3b..3d2c1d3191fb4f8b1367bf19a2f2aaf9cf64e691 100644 (file)
@@ -1,3 +1,5 @@
+#undef I3__FILE__
+#define I3__FILE__ "floating.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
@@ -175,11 +177,25 @@ void floating_enable(Con *con, bool automatic) {
             nc->rect.width = max(nc->rect.width, config.floating_minimum_width);
     }
 
-    /* add pixels for the decoration */
-    /* TODO: don’t add them when the user automatically puts new windows into
-     * 1pixel/borderless mode */
-    nc->rect.height += deco_height + 2;
-    nc->rect.width += 4;
+    /* 3: attach the child to the new parent container. We need to do this
+     * because con_border_style_rect() needs to access con->parent. */
+    con->parent = nc;
+    con->percent = 1.0;
+    con->floating = FLOATING_USER_ON;
+
+    /* 4: set the border style as specified with new_float */
+    if (automatic)
+        con->border_style = config.default_floating_border;
+
+    /* Add pixels for the decoration. */
+    Rect border_style_rect = con_border_style_rect(con);
+
+    nc->rect.height -= border_style_rect.height;
+    nc->rect.width -= border_style_rect.width;
+
+    /* Add some more pixels for the title bar */
+    if(con_border_style(con) == BS_NORMAL)
+        nc->rect.height += deco_height;
 
     /* Honor the X11 border */
     nc->rect.height += con->border_width * 2;
@@ -219,15 +235,6 @@ void floating_enable(Con *con, bool automatic) {
 
     DLOG("Floating rect: (%d, %d) with %d x %d\n", nc->rect.x, nc->rect.y, nc->rect.width, nc->rect.height);
 
-    /* 3: attach the child to the new parent container */
-    con->parent = nc;
-    con->percent = 1.0;
-    con->floating = FLOATING_USER_ON;
-
-    /* 4: set the border style as specified with new_float */
-    if (automatic)
-        con->border_style = config.default_floating_border;
-
     /* 5: Subtract the deco_height in order to make the floating window appear
      * at precisely the position it specified in its original geometry (which
      * is what applications might remember). */
@@ -493,7 +500,7 @@ void drag_pointer(Con *con, const xcb_button_press_event_t *event, xcb_window_t
                 confine_to, border_t border, callback_t callback, const void *extra)
 {
     uint32_t new_x, new_y;
-    Rect old_rect;
+    Rect old_rect = { 0, 0, 0, 0 };
     if (con != NULL)
         memcpy(&old_rect, &(con->rect), sizeof(Rect));