diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-07-20 09:28:22 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-07-22 23:10:19 +1000 |
commit | ff445cc85597ee6bfae01f03d3c246e2326f3981 (patch) | |
tree | 53c720bc54733d1660bffddf87291c887667d093 /sway/input/seat.c | |
parent | Use wlr_keyboard_get_modifiers (diff) | |
download | sway-ff445cc85597ee6bfae01f03d3c246e2326f3981.tar.gz sway-ff445cc85597ee6bfae01f03d3c246e2326f3981.tar.zst sway-ff445cc85597ee6bfae01f03d3c246e2326f3981.zip |
Implement xdg shell request_move and request_resize events
Also does a few other related things:
* Now uses enum wlr_edges instead of our own enum resize_edge
* Now uses wlr_xcursor_get_resize_name and removes our own
find_resize_edge_name
* Renames drag to move for consistency
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r-- | sway/input/seat.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c index e77d88a8..cc5b2e0f 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -1,6 +1,11 @@ | |||
1 | #define _XOPEN_SOURCE 700 | 1 | #define _XOPEN_SOURCE 700 |
2 | #define _POSIX_C_SOURCE 199309L | 2 | #define _POSIX_C_SOURCE 199309L |
3 | #include <assert.h> | 3 | #include <assert.h> |
4 | #ifdef __linux__ | ||
5 | #include <linux/input-event-codes.h> | ||
6 | #elif __FreeBSD__ | ||
7 | #include <dev/evdev/input-event-codes.h> | ||
8 | #endif | ||
4 | #include <strings.h> | 9 | #include <strings.h> |
5 | #include <time.h> | 10 | #include <time.h> |
6 | #include <wlr/types/wlr_cursor.h> | 11 | #include <wlr/types/wlr_cursor.h> |
@@ -348,6 +353,7 @@ struct sway_seat *seat_create(struct sway_input_manager *input, | |||
348 | free(seat); | 353 | free(seat); |
349 | return NULL; | 354 | return NULL; |
350 | } | 355 | } |
356 | seat->wlr_seat->data = seat; | ||
351 | 357 | ||
352 | seat->cursor = sway_cursor_create(seat); | 358 | seat->cursor = sway_cursor_create(seat); |
353 | if (!seat->cursor) { | 359 | if (!seat->cursor) { |
@@ -894,3 +900,35 @@ struct seat_config *seat_get_config(struct sway_seat *seat) { | |||
894 | 900 | ||
895 | return NULL; | 901 | return NULL; |
896 | } | 902 | } |
903 | |||
904 | void seat_begin_move(struct sway_seat *seat, struct sway_container *con) { | ||
905 | if (!seat->cursor) { | ||
906 | wlr_log(WLR_DEBUG, "Ignoring move request due to no cursor device"); | ||
907 | return; | ||
908 | } | ||
909 | seat->operation = OP_MOVE; | ||
910 | seat->op_container = con; | ||
911 | seat->op_button = BTN_LEFT; | ||
912 | } | ||
913 | |||
914 | void seat_begin_resize(struct sway_seat *seat, struct sway_container *con, | ||
915 | uint32_t button, enum wlr_edges edge) { | ||
916 | if (!seat->cursor) { | ||
917 | wlr_log(WLR_DEBUG, "Ignoring resize request due to no cursor device"); | ||
918 | return; | ||
919 | } | ||
920 | struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->wlr_seat); | ||
921 | seat->operation = OP_RESIZE; | ||
922 | seat->op_container = con; | ||
923 | seat->op_resize_preserve_ratio = keyboard && | ||
924 | (wlr_keyboard_get_modifiers(keyboard) & WLR_MODIFIER_SHIFT); | ||
925 | seat->op_resize_edge = edge == WLR_EDGE_NONE ? | ||
926 | RESIZE_EDGE_BOTTOM | RESIZE_EDGE_RIGHT : edge; | ||
927 | seat->op_button = button; | ||
928 | seat->op_ref_lx = seat->cursor->cursor->x; | ||
929 | seat->op_ref_ly = seat->cursor->cursor->y; | ||
930 | seat->op_ref_con_lx = con->x; | ||
931 | seat->op_ref_con_ly = con->y; | ||
932 | seat->op_ref_width = con->width; | ||
933 | seat->op_ref_height = con->height; | ||
934 | } | ||