aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-07-19 13:17:20 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-07-22 23:10:19 +1000
commit2c6616050a924a356b9bebbe16c9c7b8661b5d80 (patch)
tree7f423abf5412a829b9ec11f69eb0ebc315d37754
parentUse WLR_MODIFIER_SHIFT (diff)
downloadsway-2c6616050a924a356b9bebbe16c9c7b8661b5d80.tar.gz
sway-2c6616050a924a356b9bebbe16c9c7b8661b5d80.tar.zst
sway-2c6616050a924a356b9bebbe16c9c7b8661b5d80.zip
Make mod + resize do it from the top left corner
-rw-r--r--sway/input/cursor.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 3c27a7f6..e5631f5b 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -218,8 +218,6 @@ static void calculate_floating_constraints(struct sway_container *con,
218static void handle_resize_motion(struct sway_seat *seat, 218static void handle_resize_motion(struct sway_seat *seat,
219 struct sway_cursor *cursor) { 219 struct sway_cursor *cursor) {
220 struct sway_container *con = seat->op_container; 220 struct sway_container *con = seat->op_container;
221 double center_lx = con->x + con->width / 2;
222 double center_ly = con->y + con->height / 2;
223 enum resize_edge edge = seat->op_resize_edge; 221 enum resize_edge edge = seat->op_resize_edge;
224 222
225 // The amount the mouse has moved since the start of the resize operation 223 // The amount the mouse has moved since the start of the resize operation
@@ -234,10 +232,8 @@ static void handle_resize_motion(struct sway_seat *seat,
234 mouse_move_y = 0; 232 mouse_move_y = 0;
235 } 233 }
236 234
237 double grow_width = seat->op_ref_lx > center_lx ? 235 double grow_width = edge & RESIZE_EDGE_LEFT ? -mouse_move_x : mouse_move_x;
238 mouse_move_x : -mouse_move_x; 236 double grow_height = edge & RESIZE_EDGE_TOP ? -mouse_move_y : mouse_move_y;
239 double grow_height = seat->op_ref_ly > center_ly ?
240 mouse_move_y : -mouse_move_y;
241 237
242 if (seat->op_resize_preserve_ratio) { 238 if (seat->op_resize_preserve_ratio) {
243 double x_multiplier = grow_width / seat->op_ref_width; 239 double x_multiplier = grow_width / seat->op_ref_width;
@@ -247,13 +243,6 @@ static void handle_resize_motion(struct sway_seat *seat,
247 grow_height = seat->op_ref_height * avg_multiplier; 243 grow_height = seat->op_ref_height * avg_multiplier;
248 } 244 }
249 245
250 // If we're resizing from the center (mod + right click), we need to double
251 // the amount we're growing because we're doing it in both directions.
252 if (edge == RESIZE_EDGE_NONE) {
253 grow_width *= 2;
254 grow_height *= 2;
255 }
256
257 // Determine new width/height, and accommodate for min/max values 246 // Determine new width/height, and accommodate for min/max values
258 double width = seat->op_ref_width + grow_width; 247 double width = seat->op_ref_width + grow_width;
259 double height = seat->op_ref_height + grow_height; 248 double height = seat->op_ref_height + grow_height;
@@ -508,7 +497,7 @@ static void dispatch_cursor_button_floating(struct sway_cursor *cursor,
508 } 497 }
509 498
510 // Check for beginning resize 499 // Check for beginning resize
511 bool resizing_via_border = button == BTN_LEFT && edge; 500 bool resizing_via_border = button == BTN_LEFT && edge != RESIZE_EDGE_NONE;
512 bool resizing_via_mod = button == BTN_RIGHT && mod_pressed; 501 bool resizing_via_mod = button == BTN_RIGHT && mod_pressed;
513 if ((resizing_via_border || resizing_via_mod) && 502 if ((resizing_via_border || resizing_via_mod) &&
514 state == WLR_BUTTON_PRESSED) { 503 state == WLR_BUTTON_PRESSED) {
@@ -516,7 +505,8 @@ static void dispatch_cursor_button_floating(struct sway_cursor *cursor,
516 seat->op_container = cont; 505 seat->op_container = cont;
517 seat->op_resize_preserve_ratio = keyboard && 506 seat->op_resize_preserve_ratio = keyboard &&
518 (keyboard->modifiers.depressed & WLR_MODIFIER_SHIFT); 507 (keyboard->modifiers.depressed & WLR_MODIFIER_SHIFT);
519 seat->op_resize_edge = edge; 508 seat->op_resize_edge = resizing_via_mod ?
509 RESIZE_EDGE_BOTTOM | RESIZE_EDGE_RIGHT : edge;
520 seat->op_button = button; 510 seat->op_button = button;
521 seat->op_ref_lx = cursor->cursor->x; 511 seat->op_ref_lx = cursor->cursor->x;
522 seat->op_ref_ly = cursor->cursor->y; 512 seat->op_ref_ly = cursor->cursor->y;