diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-08-10 14:10:09 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-08-12 10:45:54 +1000 |
commit | b4a0363d1721b2ad2d5afb65764ecb575bd55fa4 (patch) | |
tree | f6ec316550cd113040e82a7f0cee0429fff349e5 /sway/input/seat.c | |
parent | Merge pull request #2452 from janza/position-command-fix-args (diff) | |
download | sway-b4a0363d1721b2ad2d5afb65764ecb575bd55fa4.tar.gz sway-b4a0363d1721b2ad2d5afb65764ecb575bd55fa4.tar.zst sway-b4a0363d1721b2ad2d5afb65764ecb575bd55fa4.zip |
Implement resizing tiled containers via cursor
* The OP_RESIZE seat operation has been renamed to OP_RESIZE_FLOATING,
and OP_RESIZE_TILING has been introduced.
* Similar to the above, seat_begin_resize and handle_resize_motion have
been renamed and tiling variants introduced.
* resize.c's resize_tiled has to be used, so container_resize_tiled has
been introduced in resize.c to allow external code to call it.
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r-- | sway/input/seat.c | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c index eb6d2dac..6d9e85dc 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -942,14 +942,14 @@ void seat_begin_move(struct sway_seat *seat, struct sway_container *con, | |||
942 | cursor_set_image(seat->cursor, "grab", NULL); | 942 | cursor_set_image(seat->cursor, "grab", NULL); |
943 | } | 943 | } |
944 | 944 | ||
945 | void seat_begin_resize(struct sway_seat *seat, struct sway_container *con, | 945 | void seat_begin_resize_floating(struct sway_seat *seat, |
946 | uint32_t button, enum wlr_edges edge) { | 946 | struct sway_container *con, uint32_t button, enum wlr_edges edge) { |
947 | if (!seat->cursor) { | 947 | if (!seat->cursor) { |
948 | wlr_log(WLR_DEBUG, "Ignoring resize request due to no cursor device"); | 948 | wlr_log(WLR_DEBUG, "Ignoring resize request due to no cursor device"); |
949 | return; | 949 | return; |
950 | } | 950 | } |
951 | struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->wlr_seat); | 951 | struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->wlr_seat); |
952 | seat->operation = OP_RESIZE; | 952 | seat->operation = OP_RESIZE_FLOATING; |
953 | seat->op_container = con; | 953 | seat->op_container = con; |
954 | seat->op_resize_preserve_ratio = keyboard && | 954 | seat->op_resize_preserve_ratio = keyboard && |
955 | (wlr_keyboard_get_modifiers(keyboard) & WLR_MODIFIER_SHIFT); | 955 | (wlr_keyboard_get_modifiers(keyboard) & WLR_MODIFIER_SHIFT); |
@@ -968,20 +968,29 @@ void seat_begin_resize(struct sway_seat *seat, struct sway_container *con, | |||
968 | cursor_set_image(seat->cursor, image, NULL); | 968 | cursor_set_image(seat->cursor, image, NULL); |
969 | } | 969 | } |
970 | 970 | ||
971 | void seat_begin_resize_tiling(struct sway_seat *seat, | ||
972 | struct sway_container *con, uint32_t button, enum wlr_edges edge) { | ||
973 | seat->operation = OP_RESIZE_TILING; | ||
974 | seat->op_container = con; | ||
975 | seat->op_resize_edge = edge; | ||
976 | seat->op_button = button; | ||
977 | seat->op_ref_lx = seat->cursor->cursor->x; | ||
978 | seat->op_ref_ly = seat->cursor->cursor->y; | ||
979 | seat->op_ref_con_lx = con->x; | ||
980 | seat->op_ref_con_ly = con->y; | ||
981 | seat->op_ref_width = con->width; | ||
982 | seat->op_ref_height = con->height; | ||
983 | |||
984 | const char *image = wlr_xcursor_get_resize_name(edge); | ||
985 | cursor_set_image(seat->cursor, image, NULL); | ||
986 | } | ||
987 | |||
971 | void seat_end_mouse_operation(struct sway_seat *seat) { | 988 | void seat_end_mouse_operation(struct sway_seat *seat) { |
972 | switch (seat->operation) { | 989 | if (seat->operation == OP_MOVE) { |
973 | case OP_MOVE: | 990 | // We "move" the container to its own location so it discovers its |
974 | { | 991 | // output again. |
975 | // We "move" the container to its own location so it discovers its | 992 | struct sway_container *con = seat->op_container; |
976 | // output again. | 993 | container_floating_move_to(con, con->x, con->y); |
977 | struct sway_container *con = seat->op_container; | ||
978 | container_floating_move_to(con, con->x, con->y); | ||
979 | } | ||
980 | case OP_RESIZE: | ||
981 | // Don't need to do anything here. | ||
982 | break; | ||
983 | case OP_NONE: | ||
984 | break; | ||
985 | } | 994 | } |
986 | seat->operation = OP_NONE; | 995 | seat->operation = OP_NONE; |
987 | seat->op_container = NULL; | 996 | seat->op_container = NULL; |