Bugfix: don’t overwrite the original size of floating windows when changing border style
fixes #1263
This commit is contained in:
parent
570b5729cc
commit
2e4a2d4f30
@ -57,6 +57,7 @@ int min(int a, int b);
|
|||||||
int max(int a, int b);
|
int max(int a, int b);
|
||||||
bool rect_contains(Rect rect, uint32_t x, uint32_t y);
|
bool rect_contains(Rect rect, uint32_t x, uint32_t y);
|
||||||
Rect rect_add(Rect a, Rect b);
|
Rect rect_add(Rect a, Rect b);
|
||||||
|
Rect rect_sub(Rect a, Rect b);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the name consists of only digits.
|
* Returns true if the name consists of only digits.
|
||||||
|
34
src/con.c
34
src/con.c
@ -1194,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
|
/* 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
|
* *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
|
* con->rect represent the absolute position of the window (same for
|
||||||
* the border and subtract the new border pixels. Afterwards, we update
|
* parent). Then, we change the border style and subtract the new border
|
||||||
* parent->rect to contain con. */
|
* pixels. For the parent, we do the same also for the decoration. */
|
||||||
DLOG("This is a floating container\n");
|
DLOG("This is a floating container\n");
|
||||||
|
|
||||||
|
Con *parent = con->parent;
|
||||||
Rect bsr = con_border_style_rect(con);
|
Rect bsr = con_border_style_rect(con);
|
||||||
con->rect.x += bsr.x;
|
int deco_height = (con->border_style == BS_NORMAL ? render_deco_height() : 0);
|
||||||
con->rect.y += bsr.y;
|
|
||||||
con->rect.width += bsr.width;
|
con->rect = rect_add(con->rect, bsr);
|
||||||
con->rect.height += bsr.height;
|
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. */
|
/* Change the border style, get new border/decoration values. */
|
||||||
con->border_style = border_style;
|
con->border_style = border_style;
|
||||||
con->current_border_width = border_width;
|
con->current_border_width = border_width;
|
||||||
bsr = con_border_style_rect(con);
|
bsr = con_border_style_rect(con);
|
||||||
int deco_height =
|
deco_height = (con->border_style == BS_NORMAL ? render_deco_height() : 0);
|
||||||
(con->border_style == BS_NORMAL ? render_deco_height() : 0);
|
|
||||||
|
|
||||||
con->rect.x -= bsr.x;
|
con->rect = rect_sub(con->rect, bsr);
|
||||||
con->rect.y -= bsr.y;
|
parent->rect = rect_sub(parent->rect, bsr);
|
||||||
con->rect.width -= bsr.width;
|
parent->rect.y -= deco_height;
|
||||||
con->rect.height -= bsr.height;
|
parent->rect.height += deco_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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -48,6 +48,13 @@ Rect rect_add(Rect a, Rect b) {
|
|||||||
a.height + b.height};
|
a.height + b.height};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rect rect_sub(Rect a, Rect b) {
|
||||||
|
return (Rect){a.x - b.x,
|
||||||
|
a.y - b.y,
|
||||||
|
a.width - b.width,
|
||||||
|
a.height - b.height};
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns true if the name consists of only digits.
|
* Returns true if the name consists of only digits.
|
||||||
*
|
*
|
||||||
|
@ -20,9 +20,8 @@
|
|||||||
# d805d1bbeaf89e11f67c981f94c9f55bbb4b89d9
|
# d805d1bbeaf89e11f67c981f94c9f55bbb4b89d9
|
||||||
#
|
#
|
||||||
use i3test;
|
use i3test;
|
||||||
use Data::Dumper;
|
|
||||||
|
|
||||||
fresh_workspace;
|
my $tmp = fresh_workspace;
|
||||||
|
|
||||||
my $win = open_floating_window(rect => [10, 10, 200, 100]);
|
my $win = open_floating_window(rect => [10, 10, 200, 100]);
|
||||||
|
|
||||||
@ -36,4 +35,23 @@ $geometry = $win->rect;
|
|||||||
is($geometry->{width}, 200, 'width correct');
|
is($geometry->{width}, 200, 'width correct');
|
||||||
is($geometry->{height}, 100, 'height 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;
|
done_testing;
|
||||||
|
Loading…
Reference in New Issue
Block a user