diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-07-19 13:17:20 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-07-22 23:10:19 +1000 |
commit | 2c6616050a924a356b9bebbe16c9c7b8661b5d80 (patch) | |
tree | 7f423abf5412a829b9ec11f69eb0ebc315d37754 | |
parent | 3aadf944ae0ad08439d2651d37eb3c6c686d2709 (diff) |
Make mod + resize do it from the top left corner
-rw-r--r-- | sway/input/cursor.c | 20 |
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, static void handle_resize_motion(struct sway_seat *seat, struct sway_cursor *cursor) { struct sway_container *con = seat->op_container; - double center_lx = con->x + con->width / 2; - double center_ly = con->y + con->height / 2; enum resize_edge edge = seat->op_resize_edge; // 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, mouse_move_y = 0; } - double grow_width = seat->op_ref_lx > center_lx ? - mouse_move_x : -mouse_move_x; - double grow_height = seat->op_ref_ly > center_ly ? - mouse_move_y : -mouse_move_y; + double grow_width = edge & RESIZE_EDGE_LEFT ? -mouse_move_x : mouse_move_x; + double grow_height = edge & RESIZE_EDGE_TOP ? -mouse_move_y : mouse_move_y; if (seat->op_resize_preserve_ratio) { double x_multiplier = grow_width / seat->op_ref_width; @@ -247,13 +243,6 @@ static void handle_resize_motion(struct sway_seat *seat, grow_height = seat->op_ref_height * avg_multiplier; } - // If we're resizing from the center (mod + right click), we need to double - // the amount we're growing because we're doing it in both directions. - if (edge == RESIZE_EDGE_NONE) { - grow_width *= 2; - grow_height *= 2; - } - // Determine new width/height, and accommodate for min/max values double width = seat->op_ref_width + grow_width; double height = seat->op_ref_height + grow_height; @@ -508,7 +497,7 @@ static void dispatch_cursor_button_floating(struct sway_cursor *cursor, } // Check for beginning resize - bool resizing_via_border = button == BTN_LEFT && edge; + bool resizing_via_border = button == BTN_LEFT && edge != RESIZE_EDGE_NONE; bool resizing_via_mod = button == BTN_RIGHT && mod_pressed; if ((resizing_via_border || resizing_via_mod) && state == WLR_BUTTON_PRESSED) { @@ -516,7 +505,8 @@ static void dispatch_cursor_button_floating(struct sway_cursor *cursor, seat->op_container = cont; seat->op_resize_preserve_ratio = keyboard && (keyboard->modifiers.depressed & WLR_MODIFIER_SHIFT); - seat->op_resize_edge = edge; + seat->op_resize_edge = resizing_via_mod ? + RESIZE_EDGE_BOTTOM | RESIZE_EDGE_RIGHT : edge; seat->op_button = button; seat->op_ref_lx = cursor->cursor->x; seat->op_ref_ly = cursor->cursor->y; |