Skip to content

Commit 7a294b2

Browse files
adeeemersion
authored andcommitted
Really fix floating window border resize problems
Fixes: swaywm#5250
1 parent 2262ae6 commit 7a294b2

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

sway/input/seatop_resize_floating.c

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "sway/tree/arrange.h"
88
#include "sway/tree/view.h"
99
#include "sway/tree/workspace.h"
10+
#include "sway/tree/container.h"
1011

1112
struct seatop_resize_floating_event {
1213
struct sway_container *con;
@@ -55,29 +56,37 @@ static void handle_pointer_motion(struct sway_seat *seat, uint32_t time_msec,
5556
grow_height = e->ref_height * max_multiplier;
5657
}
5758

59+
struct sway_container_state *state = &con->current;
60+
double border_width = 0.0;
61+
if (con->current.border == B_NORMAL || con->current.border == B_PIXEL) {
62+
border_width = state->border_thickness * 2;
63+
}
64+
double border_height = 0.0;
65+
if (con->current.border == B_NORMAL) {
66+
border_height += container_titlebar_height();
67+
border_height += state->border_thickness;
68+
} else if (con->current.border == B_PIXEL) {
69+
border_height += state->border_thickness * 2;
70+
}
71+
5872
// Determine new width/height, and accommodate for floating min/max values
5973
double width = e->ref_width + grow_width;
6074
double height = e->ref_height + grow_height;
6175
int min_width, max_width, min_height, max_height;
6276
floating_calculate_constraints(&min_width, &max_width,
6377
&min_height, &max_height);
64-
width = fmax(min_width, fmin(width, max_width));
65-
height = fmax(min_height, fmin(height, max_height));
78+
width = fmax(min_width + border_width, fmin(width, max_width));
79+
height = fmax(min_height + border_height, fmin(height, max_height));
6680

6781
// Apply the view's min/max size
6882
if (con->view) {
6983
double view_min_width, view_max_width, view_min_height, view_max_height;
7084
view_get_constraints(con->view, &view_min_width, &view_max_width,
7185
&view_min_height, &view_max_height);
72-
width = fmax(view_min_width, fmin(width, view_max_width));
73-
height = fmax(view_min_height, fmin(height, view_max_height));
74-
}
86+
width = fmax(view_min_width + border_width, fmin(width, view_max_width));
87+
height = fmax(view_min_height + border_height, fmin(height, view_max_height));
7588

76-
struct sway_container_state *state = &con->current;
77-
width += state->border_thickness * 2;
78-
height += config->titlebar_border_thickness * 2;
79-
height += container_titlebar_height();
80-
height += config->titlebar_v_padding;
89+
}
8190

8291
// Recalculate these, in case we hit a min/max limit
8392
grow_width = width - e->ref_width;

0 commit comments

Comments
 (0)