diff options
author | 2019-12-07 11:21:20 -0500 | |
---|---|---|
committer | 2019-12-07 12:26:21 -0500 | |
commit | 9ef026e8047a012e06497a71923c4b3bc0c9df71 (patch) | |
tree | e5dffb24c9f042988e9279a6bb2d70ee3dbc117c /sway | |
parent | A Script to change sway workspace name. (diff) | |
download | sway-9ef026e8047a012e06497a71923c4b3bc0c9df71.tar.gz sway-9ef026e8047a012e06497a71923c4b3bc0c9df71.tar.zst sway-9ef026e8047a012e06497a71923c4b3bc0c9df71.zip |
input/cursor: pass gesture events to clients
Some wayland clients (mostly GTK3 apps) like eog or evince support
gestures like pinch-to-zoom. These gestures are given to clients
via the pointer_gestures_v1 protocol. This is already supported in
wlroots, so we just need to hook up the events here in sway.
Fixes #4724
Diffstat (limited to 'sway')
-rw-r--r-- | sway/input/cursor.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 574186d7..6d88cd54 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -735,6 +735,60 @@ static void handle_request_set_cursor(struct wl_listener *listener, | |||
735 | event->hotspot_y, focused_client); | 735 | event->hotspot_y, focused_client); |
736 | } | 736 | } |
737 | 737 | ||
738 | static void handle_pointer_pinch_begin(struct wl_listener *listener, void *data) { | ||
739 | struct sway_cursor *cursor = wl_container_of( | ||
740 | listener, cursor, pinch_begin); | ||
741 | struct wlr_event_pointer_pinch_begin *event = data; | ||
742 | wlr_pointer_gestures_v1_send_pinch_begin( | ||
743 | cursor->pointer_gestures, cursor->seat->wlr_seat, | ||
744 | event->time_msec, event->fingers); | ||
745 | } | ||
746 | |||
747 | static void handle_pointer_pinch_update(struct wl_listener *listener, void *data) { | ||
748 | struct sway_cursor *cursor = wl_container_of( | ||
749 | listener, cursor, pinch_update); | ||
750 | struct wlr_event_pointer_pinch_update *event = data; | ||
751 | wlr_pointer_gestures_v1_send_pinch_update( | ||
752 | cursor->pointer_gestures, cursor->seat->wlr_seat, | ||
753 | event->time_msec, event->dx, event->dy, | ||
754 | event->scale, event->rotation); | ||
755 | } | ||
756 | |||
757 | static void handle_pointer_pinch_end(struct wl_listener *listener, void *data) { | ||
758 | struct sway_cursor *cursor = wl_container_of( | ||
759 | listener, cursor, pinch_end); | ||
760 | struct wlr_event_pointer_pinch_end *event = data; | ||
761 | wlr_pointer_gestures_v1_send_pinch_end( | ||
762 | cursor->pointer_gestures, cursor->seat->wlr_seat, | ||
763 | event->time_msec, event->cancelled); | ||
764 | } | ||
765 | |||
766 | static void handle_pointer_swipe_begin(struct wl_listener *listener, void *data) { | ||
767 | struct sway_cursor *cursor = wl_container_of( | ||
768 | listener, cursor, swipe_begin); | ||
769 | struct wlr_event_pointer_swipe_begin *event = data; | ||
770 | wlr_pointer_gestures_v1_send_swipe_begin( | ||
771 | cursor->pointer_gestures, cursor->seat->wlr_seat, | ||
772 | event->time_msec, event->fingers); | ||
773 | } | ||
774 | |||
775 | static void handle_pointer_swipe_update(struct wl_listener *listener, void *data) { | ||
776 | struct sway_cursor *cursor = wl_container_of( | ||
777 | listener, cursor, swipe_update); | ||
778 | struct wlr_event_pointer_swipe_update *event = data; | ||
779 | wlr_pointer_gestures_v1_send_swipe_update( | ||
780 | cursor->pointer_gestures, cursor->seat->wlr_seat, | ||
781 | event->time_msec, event->dx, event->dy); | ||
782 | } | ||
783 | |||
784 | static void handle_pointer_swipe_end(struct wl_listener *listener, void *data) { | ||
785 | struct sway_cursor *cursor = wl_container_of( | ||
786 | listener, cursor, swipe_end); | ||
787 | struct wlr_event_pointer_swipe_end *event = data; | ||
788 | wlr_pointer_gestures_v1_send_swipe_end( | ||
789 | cursor->pointer_gestures, cursor->seat->wlr_seat, | ||
790 | event->time_msec, event->cancelled); | ||
791 | } | ||
738 | void cursor_set_image(struct sway_cursor *cursor, const char *image, | 792 | void cursor_set_image(struct sway_cursor *cursor, const char *image, |
739 | struct wl_client *client) { | 793 | struct wl_client *client) { |
740 | if (!(cursor->seat->wlr_seat->capabilities & WL_SEAT_CAPABILITY_POINTER)) { | 794 | if (!(cursor->seat->wlr_seat->capabilities & WL_SEAT_CAPABILITY_POINTER)) { |
@@ -825,6 +879,20 @@ struct sway_cursor *sway_cursor_create(struct sway_seat *seat) { | |||
825 | cursor->hide_source = wl_event_loop_add_timer(server.wl_event_loop, | 879 | cursor->hide_source = wl_event_loop_add_timer(server.wl_event_loop, |
826 | hide_notify, cursor); | 880 | hide_notify, cursor); |
827 | 881 | ||
882 | cursor->pointer_gestures = wlr_pointer_gestures_v1_create(server.wl_display); | ||
883 | cursor->pinch_begin.notify = handle_pointer_pinch_begin; | ||
884 | wl_signal_add(&wlr_cursor->events.pinch_begin, &cursor->pinch_begin); | ||
885 | cursor->pinch_update.notify = handle_pointer_pinch_update; | ||
886 | wl_signal_add(&wlr_cursor->events.pinch_update, &cursor->pinch_update); | ||
887 | cursor->pinch_end.notify = handle_pointer_pinch_end; | ||
888 | wl_signal_add(&wlr_cursor->events.pinch_end, &cursor->pinch_end); | ||
889 | cursor->swipe_begin.notify = handle_pointer_swipe_begin; | ||
890 | wl_signal_add(&wlr_cursor->events.swipe_begin, &cursor->swipe_begin); | ||
891 | cursor->swipe_update.notify = handle_pointer_swipe_update; | ||
892 | wl_signal_add(&wlr_cursor->events.swipe_update, &cursor->swipe_update); | ||
893 | cursor->swipe_end.notify = handle_pointer_swipe_end; | ||
894 | wl_signal_add(&wlr_cursor->events.swipe_end, &cursor->swipe_end); | ||
895 | |||
828 | // input events | 896 | // input events |
829 | wl_signal_add(&wlr_cursor->events.motion, &cursor->motion); | 897 | wl_signal_add(&wlr_cursor->events.motion, &cursor->motion); |
830 | cursor->motion.notify = handle_cursor_motion_relative; | 898 | cursor->motion.notify = handle_cursor_motion_relative; |