diff options
author | Adam Kürthy <adikurthy@gmail.com> | 2020-05-04 02:18:39 +0200 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-05-13 11:07:31 +0200 |
commit | 7a294b266839a63c871eeb72b2354dbbebcf15ec (patch) | |
tree | 7de83a1e3f487327957e7a013cc0c5f4f3808d76 | |
parent | input/cursor: don't apply pointer constraint to emulated tablet input (diff) | |
download | sway-7a294b266839a63c871eeb72b2354dbbebcf15ec.tar.gz sway-7a294b266839a63c871eeb72b2354dbbebcf15ec.tar.zst sway-7a294b266839a63c871eeb72b2354dbbebcf15ec.zip |
Really fix floating window border resize problems
Fixes: https://github.com/swaywm/sway/pull/5250
-rw-r--r-- | sway/input/seatop_resize_floating.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/sway/input/seatop_resize_floating.c b/sway/input/seatop_resize_floating.c index c9fa1e9b..80df63ce 100644 --- a/sway/input/seatop_resize_floating.c +++ b/sway/input/seatop_resize_floating.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include "sway/tree/arrange.h" | 7 | #include "sway/tree/arrange.h" |
8 | #include "sway/tree/view.h" | 8 | #include "sway/tree/view.h" |
9 | #include "sway/tree/workspace.h" | 9 | #include "sway/tree/workspace.h" |
10 | #include "sway/tree/container.h" | ||
10 | 11 | ||
11 | struct seatop_resize_floating_event { | 12 | struct seatop_resize_floating_event { |
12 | struct sway_container *con; | 13 | struct sway_container *con; |
@@ -55,29 +56,37 @@ static void handle_pointer_motion(struct sway_seat *seat, uint32_t time_msec, | |||
55 | grow_height = e->ref_height * max_multiplier; | 56 | grow_height = e->ref_height * max_multiplier; |
56 | } | 57 | } |
57 | 58 | ||
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 | |||
58 | // Determine new width/height, and accommodate for floating min/max values | 72 | // Determine new width/height, and accommodate for floating min/max values |
59 | double width = e->ref_width + grow_width; | 73 | double width = e->ref_width + grow_width; |
60 | double height = e->ref_height + grow_height; | 74 | double height = e->ref_height + grow_height; |
61 | int min_width, max_width, min_height, max_height; | 75 | int min_width, max_width, min_height, max_height; |
62 | floating_calculate_constraints(&min_width, &max_width, | 76 | floating_calculate_constraints(&min_width, &max_width, |
63 | &min_height, &max_height); | 77 | &min_height, &max_height); |
64 | width = fmax(min_width, fmin(width, max_width)); | 78 | width = fmax(min_width + border_width, fmin(width, max_width)); |
65 | height = fmax(min_height, fmin(height, max_height)); | 79 | height = fmax(min_height + border_height, fmin(height, max_height)); |
66 | 80 | ||
67 | // Apply the view's min/max size | 81 | // Apply the view's min/max size |
68 | if (con->view) { | 82 | if (con->view) { |
69 | double view_min_width, view_max_width, view_min_height, view_max_height; | 83 | double view_min_width, view_max_width, view_min_height, view_max_height; |
70 | view_get_constraints(con->view, &view_min_width, &view_max_width, | 84 | view_get_constraints(con->view, &view_min_width, &view_max_width, |
71 | &view_min_height, &view_max_height); | 85 | &view_min_height, &view_max_height); |
72 | width = fmax(view_min_width, fmin(width, view_max_width)); | 86 | width = fmax(view_min_width + border_width, fmin(width, view_max_width)); |
73 | height = fmax(view_min_height, fmin(height, view_max_height)); | 87 | height = fmax(view_min_height + border_height, fmin(height, view_max_height)); |
74 | } | ||
75 | 88 | ||
76 | struct sway_container_state *state = &con->current; | 89 | } |
77 | width += state->border_thickness * 2; | ||
78 | height += config->titlebar_border_thickness * 2; | ||
79 | height += container_titlebar_height(); | ||
80 | height += config->titlebar_v_padding; | ||
81 | 90 | ||
82 | // Recalculate these, in case we hit a min/max limit | 91 | // Recalculate these, in case we hit a min/max limit |
83 | grow_width = width - e->ref_width; | 92 | grow_width = width - e->ref_width; |