diff options
Diffstat (limited to 'sway/input/seatop_resize_floating.c')
-rw-r--r-- | sway/input/seatop_resize_floating.c | 57 |
1 files changed, 34 insertions, 23 deletions
diff --git a/sway/input/seatop_resize_floating.c b/sway/input/seatop_resize_floating.c index 5da22e47..bec86e33 100644 --- a/sway/input/seatop_resize_floating.c +++ b/sway/input/seatop_resize_floating.c | |||
@@ -1,7 +1,7 @@ | |||
1 | #define _POSIX_C_SOURCE 200809L | ||
2 | #include <limits.h> | 1 | #include <limits.h> |
3 | #include <wlr/types/wlr_cursor.h> | 2 | #include <wlr/types/wlr_cursor.h> |
4 | #include <wlr/types/wlr_xcursor_manager.h> | 3 | #include <wlr/types/wlr_xcursor_manager.h> |
4 | #include "sway/desktop/transaction.h" | ||
5 | #include "sway/input/cursor.h" | 5 | #include "sway/input/cursor.h" |
6 | #include "sway/input/seat.h" | 6 | #include "sway/input/seat.h" |
7 | #include "sway/tree/arrange.h" | 7 | #include "sway/tree/arrange.h" |
@@ -20,13 +20,14 @@ struct seatop_resize_floating_event { | |||
20 | 20 | ||
21 | static void handle_button(struct sway_seat *seat, uint32_t time_msec, | 21 | static void handle_button(struct sway_seat *seat, uint32_t time_msec, |
22 | struct wlr_input_device *device, uint32_t button, | 22 | struct wlr_input_device *device, uint32_t button, |
23 | enum wlr_button_state state) { | 23 | enum wl_pointer_button_state state) { |
24 | struct seatop_resize_floating_event *e = seat->seatop_data; | 24 | struct seatop_resize_floating_event *e = seat->seatop_data; |
25 | struct sway_container *con = e->con; | 25 | struct sway_container *con = e->con; |
26 | 26 | ||
27 | if (seat->cursor->pressed_button_count == 0) { | 27 | if (seat->cursor->pressed_button_count == 0) { |
28 | container_set_resizing(con, false); | 28 | container_set_resizing(con, false); |
29 | arrange_container(con); // Send configure w/o resizing hint | 29 | arrange_container(con); // Send configure w/o resizing hint |
30 | transaction_commit_dirty(); | ||
30 | seatop_begin_default(seat); | 31 | seatop_begin_default(seat); |
31 | } | 32 | } |
32 | } | 33 | } |
@@ -78,17 +79,25 @@ static void handle_pointer_motion(struct sway_seat *seat, uint32_t time_msec) { | |||
78 | double height = e->ref_height + grow_height; | 79 | double height = e->ref_height + grow_height; |
79 | int min_width, max_width, min_height, max_height; | 80 | int min_width, max_width, min_height, max_height; |
80 | floating_calculate_constraints(&min_width, &max_width, | 81 | floating_calculate_constraints(&min_width, &max_width, |
81 | &min_height, &max_height); | 82 | &min_height, &max_height); |
82 | width = fmax(min_width + border_width, fmin(width, max_width)); | 83 | width = fmin(width, max_width - border_width); |
83 | height = fmax(min_height + border_height, fmin(height, max_height)); | 84 | width = fmax(width, min_width + border_width); |
85 | width = fmax(width, 1); | ||
86 | height = fmin(height, max_height - border_height); | ||
87 | height = fmax(height, min_height + border_height); | ||
88 | height = fmax(height, 1); | ||
84 | 89 | ||
85 | // Apply the view's min/max size | 90 | // Apply the view's min/max size |
86 | if (con->view) { | 91 | if (con->view) { |
87 | double view_min_width, view_max_width, view_min_height, view_max_height; | 92 | double view_min_width, view_max_width, view_min_height, view_max_height; |
88 | view_get_constraints(con->view, &view_min_width, &view_max_width, | 93 | view_get_constraints(con->view, &view_min_width, &view_max_width, |
89 | &view_min_height, &view_max_height); | 94 | &view_min_height, &view_max_height); |
90 | width = fmax(view_min_width + border_width, fmin(width, view_max_width)); | 95 | width = fmin(width, view_max_width - border_width); |
91 | height = fmax(view_min_height + border_height, fmin(height, view_max_height)); | 96 | width = fmax(width, view_min_width + border_width); |
97 | width = fmax(width, 1); | ||
98 | height = fmin(height, view_max_height - border_height); | ||
99 | height = fmax(height, view_min_height + border_height); | ||
100 | height = fmax(height, 1); | ||
92 | 101 | ||
93 | } | 102 | } |
94 | 103 | ||
@@ -116,23 +125,24 @@ static void handle_pointer_motion(struct sway_seat *seat, uint32_t time_msec) { | |||
116 | 125 | ||
117 | // Determine the amounts we need to bump everything relative to the current | 126 | // Determine the amounts we need to bump everything relative to the current |
118 | // size. | 127 | // size. |
119 | int relative_grow_width = width - con->width; | 128 | int relative_grow_width = width - con->pending.width; |
120 | int relative_grow_height = height - con->height; | 129 | int relative_grow_height = height - con->pending.height; |
121 | int relative_grow_x = (e->ref_con_lx + grow_x) - con->x; | 130 | int relative_grow_x = (e->ref_con_lx + grow_x) - con->pending.x; |
122 | int relative_grow_y = (e->ref_con_ly + grow_y) - con->y; | 131 | int relative_grow_y = (e->ref_con_ly + grow_y) - con->pending.y; |
123 | 132 | ||
124 | // Actually resize stuff | 133 | // Actually resize stuff |
125 | con->x += relative_grow_x; | 134 | con->pending.x += relative_grow_x; |
126 | con->y += relative_grow_y; | 135 | con->pending.y += relative_grow_y; |
127 | con->width += relative_grow_width; | 136 | con->pending.width += relative_grow_width; |
128 | con->height += relative_grow_height; | 137 | con->pending.height += relative_grow_height; |
129 | 138 | ||
130 | con->content_x += relative_grow_x; | 139 | con->pending.content_x += relative_grow_x; |
131 | con->content_y += relative_grow_y; | 140 | con->pending.content_y += relative_grow_y; |
132 | con->content_width += relative_grow_width; | 141 | con->pending.content_width += relative_grow_width; |
133 | con->content_height += relative_grow_height; | 142 | con->pending.content_height += relative_grow_height; |
134 | 143 | ||
135 | arrange_container(con); | 144 | arrange_container(con); |
145 | transaction_commit_dirty(); | ||
136 | } | 146 | } |
137 | 147 | ||
138 | static void handle_unref(struct sway_seat *seat, struct sway_container *con) { | 148 | static void handle_unref(struct sway_seat *seat, struct sway_container *con) { |
@@ -166,16 +176,17 @@ void seatop_begin_resize_floating(struct sway_seat *seat, | |||
166 | e->edge = edge == WLR_EDGE_NONE ? WLR_EDGE_BOTTOM | WLR_EDGE_RIGHT : edge; | 176 | e->edge = edge == WLR_EDGE_NONE ? WLR_EDGE_BOTTOM | WLR_EDGE_RIGHT : edge; |
167 | e->ref_lx = seat->cursor->cursor->x; | 177 | e->ref_lx = seat->cursor->cursor->x; |
168 | e->ref_ly = seat->cursor->cursor->y; | 178 | e->ref_ly = seat->cursor->cursor->y; |
169 | e->ref_con_lx = con->x; | 179 | e->ref_con_lx = con->pending.x; |
170 | e->ref_con_ly = con->y; | 180 | e->ref_con_ly = con->pending.y; |
171 | e->ref_width = con->width; | 181 | e->ref_width = con->pending.width; |
172 | e->ref_height = con->height; | 182 | e->ref_height = con->pending.height; |
173 | 183 | ||
174 | seat->seatop_impl = &seatop_impl; | 184 | seat->seatop_impl = &seatop_impl; |
175 | seat->seatop_data = e; | 185 | seat->seatop_data = e; |
176 | 186 | ||
177 | container_set_resizing(con, true); | 187 | container_set_resizing(con, true); |
178 | container_raise_floating(con); | 188 | container_raise_floating(con); |
189 | transaction_commit_dirty(); | ||
179 | 190 | ||
180 | const char *image = edge == WLR_EDGE_NONE ? | 191 | const char *image = edge == WLR_EDGE_NONE ? |
181 | "se-resize" : wlr_xcursor_get_resize_name(edge); | 192 | "se-resize" : wlr_xcursor_get_resize_name(edge); |