/* 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);
+ 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;
-
- 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;
}
/*
# d805d1bbeaf89e11f67c981f94c9f55bbb4b89d9
#
use i3test;
-use Data::Dumper;
-fresh_workspace;
+my $tmp = fresh_workspace;
my $win = open_floating_window(rect => [10, 10, 200, 100]);
is($geometry->{width}, 200, 'width correct');
is($geometry->{height}, 100, 'height correct');
+################################################################################
+# When in fullscreen mode, the original position must not be overwritten.
+################################################################################
+
+sub get_floating_con_rect {
+ my ($nodes, $focus) = get_ws($tmp);
+ my $floating_con = $nodes->{floating_nodes}->[0];
+ return $floating_con->{rect};
+}
+my $old_rect = get_floating_con_rect();
+
+cmd 'fullscreen';
+
+is_deeply(get_floating_con_rect(), $old_rect, 'Rect the same after going into fullscreen');
+
+cmd 'border pixel 2';
+
+is_deeply(get_floating_con_rect(), $old_rect, 'Rect the same after changing border style');
+
done_testing;