From 9fe8e379613c42338920e913c6ffd6d1c273da67 Mon Sep 17 00:00:00 2001 From: Greg V Date: Sat, 26 Jan 2019 01:51:38 +0300 Subject: Implement the pointer-gestures-unstable-v1 protocol This protocol relays touchpad gesture events produced by libinput to supporting clients (e.g. Evince, Eye of GNOME). --- include/backend/libinput.h | 12 +++++ include/rootston/cursor.h | 6 +++ include/rootston/desktop.h | 2 + include/wlr/types/meson.build | 1 + include/wlr/types/wlr_cursor.h | 6 +++ include/wlr/types/wlr_pointer.h | 52 ++++++++++++++++++++ include/wlr/types/wlr_pointer_gestures_v1.h | 73 +++++++++++++++++++++++++++++ 7 files changed, 152 insertions(+) create mode 100644 include/wlr/types/wlr_pointer_gestures_v1.h (limited to 'include') diff --git a/include/backend/libinput.h b/include/backend/libinput.h index f4886956..ddb81a5a 100644 --- a/include/backend/libinput.h +++ b/include/backend/libinput.h @@ -54,6 +54,18 @@ void handle_pointer_button(struct libinput_event *event, struct libinput_device *device); void handle_pointer_axis(struct libinput_event *event, struct libinput_device *device); +void handle_pointer_swipe_begin(struct libinput_event *event, + struct libinput_device *device); +void handle_pointer_swipe_update(struct libinput_event *event, + struct libinput_device *device); +void handle_pointer_swipe_end(struct libinput_event *event, + struct libinput_device *device); +void handle_pointer_pinch_begin(struct libinput_event *event, + struct libinput_device *device); +void handle_pointer_pinch_update(struct libinput_event *event, + struct libinput_device *device); +void handle_pointer_pinch_end(struct libinput_event *event, + struct libinput_device *device); struct wlr_switch *create_libinput_switch( struct libinput_device *device); diff --git a/include/rootston/cursor.h b/include/rootston/cursor.h index d1db6856..0d6b6014 100644 --- a/include/rootston/cursor.h +++ b/include/rootston/cursor.h @@ -39,6 +39,12 @@ struct roots_cursor { struct wl_listener button; struct wl_listener axis; struct wl_listener frame; + struct wl_listener swipe_begin; + struct wl_listener swipe_update; + struct wl_listener swipe_end; + struct wl_listener pinch_begin; + struct wl_listener pinch_update; + struct wl_listener pinch_end; struct wl_listener touch_down; struct wl_listener touch_up; diff --git a/include/rootston/desktop.h b/include/rootston/desktop.h index 56d2a129..d8fc53e2 100644 --- a/include/rootston/desktop.h +++ b/include/rootston/desktop.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -67,6 +68,7 @@ struct roots_desktop { struct wlr_presentation *presentation; struct wlr_foreign_toplevel_manager_v1 *foreign_toplevel_manager_v1; struct wlr_relative_pointer_manager_v1 *relative_pointer_manager; + struct wlr_pointer_gestures_v1 *pointer_gestures; struct wl_listener new_output; struct wl_listener layout_change; diff --git a/include/wlr/types/meson.build b/include/wlr/types/meson.build index 86f128b6..82715ad1 100644 --- a/include/wlr/types/meson.build +++ b/include/wlr/types/meson.build @@ -25,6 +25,7 @@ install_headers( 'wlr_output_layout.h', 'wlr_output.h', 'wlr_pointer_constraints_v1.h', + 'wlr_pointer_gestures_v1.h', 'wlr_pointer.h', 'wlr_presentation_time.h', 'wlr_primary_selection.h', diff --git a/include/wlr/types/wlr_cursor.h b/include/wlr/types/wlr_cursor.h index 6475669c..192ba8a0 100644 --- a/include/wlr/types/wlr_cursor.h +++ b/include/wlr/types/wlr_cursor.h @@ -52,6 +52,12 @@ struct wlr_cursor { struct wl_signal button; struct wl_signal axis; struct wl_signal frame; + struct wl_signal swipe_begin; + struct wl_signal swipe_update; + struct wl_signal swipe_end; + struct wl_signal pinch_begin; + struct wl_signal pinch_update; + struct wl_signal pinch_end; struct wl_signal touch_up; struct wl_signal touch_down; diff --git a/include/wlr/types/wlr_pointer.h b/include/wlr/types/wlr_pointer.h index 9dfe7aaa..486e1bc9 100644 --- a/include/wlr/types/wlr_pointer.h +++ b/include/wlr/types/wlr_pointer.h @@ -24,6 +24,12 @@ struct wlr_pointer { struct wl_signal button; struct wl_signal axis; struct wl_signal frame; + struct wl_signal swipe_begin; + struct wl_signal swipe_update; + struct wl_signal swipe_end; + struct wl_signal pinch_begin; + struct wl_signal pinch_update; + struct wl_signal pinch_end; } events; void *data; @@ -71,4 +77,50 @@ struct wlr_event_pointer_axis { int32_t delta_discrete; }; +struct wlr_event_pointer_swipe_begin { + struct wlr_input_device *device; + uint32_t time_msec; + uint32_t fingers; +}; + +struct wlr_event_pointer_swipe_update { + struct wlr_input_device *device; + uint32_t time_msec; + uint32_t fingers; + // Relative coordinates of the logical center of the gesture + // compared to the previous event. + double dx, dy; +}; + +struct wlr_event_pointer_swipe_end { + struct wlr_input_device *device; + uint32_t time_msec; + bool cancelled; +}; + +struct wlr_event_pointer_pinch_begin { + struct wlr_input_device *device; + uint32_t time_msec; + uint32_t fingers; +}; + +struct wlr_event_pointer_pinch_update { + struct wlr_input_device *device; + uint32_t time_msec; + uint32_t fingers; + // Relative coordinates of the logical center of the gesture + // compared to the previous event. + double dx, dy; + // Absolute scale compared to the begin event + double scale; + // Relative angle in degrees clockwise compared to the previous event. + double rotation; +}; + +struct wlr_event_pointer_pinch_end { + struct wlr_input_device *device; + uint32_t time_msec; + bool cancelled; +}; + #endif diff --git a/include/wlr/types/wlr_pointer_gestures_v1.h b/include/wlr/types/wlr_pointer_gestures_v1.h new file mode 100644 index 00000000..7caf0f53 --- /dev/null +++ b/include/wlr/types/wlr_pointer_gestures_v1.h @@ -0,0 +1,73 @@ +/* + * This an unstable interface of wlroots. No guarantees are made regarding the + * future consistency of this API. + */ +#ifndef WLR_USE_UNSTABLE +#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" +#endif + +#ifndef WLR_TYPES_WLR_POINTER_GESTURES_V1_H +#define WLR_TYPES_WLR_POINTER_GESTURES_V1_H + +#include +#include +#include + +struct wlr_pointer_gestures_v1 { + struct wl_global *global; + struct wl_list resources; // wl_resource_get_link + struct wl_list swipes; // wl_resource_get_link + struct wl_list pinches; // wl_resource_get_link + + struct wl_listener display_destroy; + + struct { + struct wl_signal destroy; + } events; + + void *data; +}; + +struct wlr_pointer_gestures_v1 *wlr_pointer_gestures_v1_create( + struct wl_display *display); + +void wlr_pointer_gestures_v1_send_swipe_begin( + struct wlr_pointer_gestures_v1 *gestures, + struct wlr_seat *seat, + uint32_t time_msec, + uint32_t fingers); +void wlr_pointer_gestures_v1_send_swipe_update( + struct wlr_pointer_gestures_v1 *gestures, + struct wlr_seat *seat, + uint32_t time_msec, + double dx, + double dy); +void wlr_pointer_gestures_v1_send_swipe_end( + struct wlr_pointer_gestures_v1 *gestures, + struct wlr_seat *seat, + uint32_t time_msec, + bool cancelled); + +void wlr_pointer_gestures_v1_send_pinch_begin( + struct wlr_pointer_gestures_v1 *gestures, + struct wlr_seat *seat, + uint32_t time_msec, + uint32_t fingers); +void wlr_pointer_gestures_v1_send_pinch_update( + struct wlr_pointer_gestures_v1 *gestures, + struct wlr_seat *seat, + uint32_t time_msec, + double dx, + double dy, + double scale, + double rotation); +void wlr_pointer_gestures_v1_send_pinch_end( + struct wlr_pointer_gestures_v1 *gestures, + struct wlr_seat *seat, + uint32_t time_msec, + bool cancelled); + +void wlr_pointer_gestures_v1_destroy( + struct wlr_pointer_gestures_v1 *pointer_gestures_v1); + +#endif -- cgit v1.2.3