aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorJosé Expósito <jose.exposito89@gmail.com>2021-07-12 19:51:21 +0200
committerSimon Ser <contact@emersion.fr>2021-09-27 15:30:31 +0200
commit62e62b69420e22471ef384194ba4d4fb91ddd7df (patch)
tree91f823cacd5b0edefcbadaae9bbbaf023f1bec06 /backend
parent52d249193190c44d1f1d07c36ae57f1dfa16a9e0 (diff)
backend/wayland: send hold gesture events
Receive hold gesture events using a Wayland listiner and emit the appropiate wlr_pointer signal.
Diffstat (limited to 'backend')
-rw-r--r--backend/wayland/backend.c2
-rw-r--r--backend/wayland/seat.c44
2 files changed, 45 insertions, 1 deletions
diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c
index c11d25ca..6c34ff27 100644
--- a/backend/wayland/backend.c
+++ b/backend/wayland/backend.c
@@ -224,7 +224,7 @@ static void registry_global(void *data, struct wl_registry *registry,
&zxdg_decoration_manager_v1_interface, 1);
} else if (strcmp(iface, zwp_pointer_gestures_v1_interface.name) == 0) {
wl->zwp_pointer_gestures_v1 = wl_registry_bind(registry, name,
- &zwp_pointer_gestures_v1_interface, 1);
+ &zwp_pointer_gestures_v1_interface, version < 3 ? version : 3);
} else if (strcmp(iface, wp_presentation_interface.name) == 0) {
wl->presentation = wl_registry_bind(registry, name,
&wp_presentation_interface, 1);
diff --git a/backend/wayland/seat.c b/backend/wayland/seat.c
index 05524a7e..508551a0 100644
--- a/backend/wayland/seat.c
+++ b/backend/wayland/seat.c
@@ -504,6 +504,9 @@ static void pointer_destroy(struct wlr_pointer *wlr_pointer) {
if (pointer->gesture_pinch != NULL) {
zwp_pointer_gesture_pinch_v1_destroy(pointer->gesture_pinch);
}
+ if (pointer->gesture_hold != NULL) {
+ zwp_pointer_gesture_hold_v1_destroy(pointer->gesture_hold);
+ }
if (pointer->relative_pointer != NULL) {
zwp_relative_pointer_v1_destroy(pointer->relative_pointer);
}
@@ -616,6 +619,38 @@ static const struct zwp_pointer_gesture_pinch_v1_listener gesture_pinch_impl = {
.end = gesture_pinch_end,
};
+static void gesture_hold_begin(void *data,
+ struct zwp_pointer_gesture_hold_v1 *zwp_pointer_gesture_hold_v1,
+ uint32_t serial, uint32_t time,
+ struct wl_surface *surface, uint32_t fingers) {
+ struct wlr_wl_input_device *input_device = (struct wlr_wl_input_device *)data;
+ struct wlr_input_device *wlr_dev = &input_device->wlr_input_device;
+ struct wlr_event_pointer_hold_begin wlr_event = {
+ .device = wlr_dev,
+ .time_msec = time,
+ .fingers = fingers,
+ };
+ input_device->fingers = fingers;
+ wlr_signal_emit_safe(&wlr_dev->pointer->events.hold_begin, &wlr_event);
+}
+
+static void gesture_hold_end(void *data,
+ struct zwp_pointer_gesture_hold_v1 *zwp_pointer_gesture_hold_v1,
+ uint32_t serial, uint32_t time, int32_t cancelled) {
+ struct wlr_wl_input_device *input_device = (struct wlr_wl_input_device *)data;
+ struct wlr_input_device *wlr_dev = &input_device->wlr_input_device;
+ struct wlr_event_pointer_hold_end wlr_event = {
+ .device = wlr_dev,
+ .time_msec = time,
+ .cancelled = cancelled,
+ };
+ wlr_signal_emit_safe(&wlr_dev->pointer->events.hold_end, &wlr_event);
+}
+
+static const struct zwp_pointer_gesture_hold_v1_listener gesture_hold_impl = {
+ .begin = gesture_hold_begin,
+ .end = gesture_hold_end,
+};
static void relative_pointer_handle_relative_motion(void *data,
struct zwp_relative_pointer_v1 *relative_pointer, uint32_t utime_hi,
@@ -690,12 +725,21 @@ void create_wl_pointer(struct wlr_wl_seat *seat, struct wlr_wl_output *output) {
wlr_pointer_init(wlr_dev->pointer, &pointer_impl);
if (backend->zwp_pointer_gestures_v1) {
+ uint32_t version = zwp_pointer_gestures_v1_get_version(
+ backend->zwp_pointer_gestures_v1);
+
pointer->gesture_swipe = zwp_pointer_gestures_v1_get_swipe_gesture(
backend->zwp_pointer_gestures_v1, wl_pointer);
zwp_pointer_gesture_swipe_v1_add_listener(pointer->gesture_swipe, &gesture_swipe_impl, dev);
pointer->gesture_pinch = zwp_pointer_gestures_v1_get_pinch_gesture(
backend->zwp_pointer_gestures_v1, wl_pointer);
zwp_pointer_gesture_pinch_v1_add_listener(pointer->gesture_pinch, &gesture_pinch_impl, dev);
+
+ if (version >= ZWP_POINTER_GESTURES_V1_GET_HOLD_GESTURE) {
+ pointer->gesture_hold = zwp_pointer_gestures_v1_get_hold_gesture(
+ backend->zwp_pointer_gestures_v1, wl_pointer);
+ zwp_pointer_gesture_hold_v1_add_listener(pointer->gesture_hold, &gesture_hold_impl, dev);
+ }
}
if (backend->zwp_relative_pointer_manager_v1) {