aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/libinput/events.c8
-rw-r--r--backend/libinput/pointer.c38
-rw-r--r--include/backend/libinput.h4
3 files changed, 50 insertions, 0 deletions
diff --git a/backend/libinput/events.c b/backend/libinput/events.c
index f149b2f1..82883779 100644
--- a/backend/libinput/events.c
+++ b/backend/libinput/events.c
@@ -316,6 +316,14 @@ void handle_libinput_event(struct wlr_libinput_backend *backend,
case LIBINPUT_EVENT_GESTURE_PINCH_END:
handle_pointer_pinch_end(event, libinput_dev);
break;
+#if LIBINPUT_HAS_HOLD_GESTURES
+ case LIBINPUT_EVENT_GESTURE_HOLD_BEGIN:
+ handle_pointer_hold_begin(event, libinput_dev);
+ break;
+ case LIBINPUT_EVENT_GESTURE_HOLD_END:
+ handle_pointer_hold_end(event, libinput_dev);
+ break;
+#endif
default:
wlr_log(WLR_DEBUG, "Unknown libinput event %d", event_type);
break;
diff --git a/backend/libinput/pointer.c b/backend/libinput/pointer.c
index 2e799df6..520f98dc 100644
--- a/backend/libinput/pointer.c
+++ b/backend/libinput/pointer.c
@@ -260,3 +260,41 @@ void handle_pointer_pinch_end(struct libinput_event *event,
};
wlr_signal_emit_safe(&wlr_dev->pointer->events.pinch_end, &wlr_event);
}
+
+void handle_pointer_hold_begin(struct libinput_event *event,
+ struct libinput_device *libinput_dev) {
+ struct wlr_input_device *wlr_dev =
+ get_appropriate_device(WLR_INPUT_DEVICE_POINTER, libinput_dev);
+ if (!wlr_dev) {
+ wlr_log(WLR_DEBUG, "Got a pointer gesture event for a device with no pointers?");
+ return;
+ }
+ struct libinput_event_gesture *gevent =
+ libinput_event_get_gesture_event(event);
+ struct wlr_event_pointer_hold_begin wlr_event = {
+ .device = wlr_dev,
+ .time_msec =
+ usec_to_msec(libinput_event_gesture_get_time_usec(gevent)),
+ .fingers = libinput_event_gesture_get_finger_count(gevent),
+ };
+ wlr_signal_emit_safe(&wlr_dev->pointer->events.hold_begin, &wlr_event);
+}
+
+void handle_pointer_hold_end(struct libinput_event *event,
+ struct libinput_device *libinput_dev) {
+ struct wlr_input_device *wlr_dev =
+ get_appropriate_device(WLR_INPUT_DEVICE_POINTER, libinput_dev);
+ if (!wlr_dev) {
+ wlr_log(WLR_DEBUG, "Got a pointer gesture event for a device with no pointers?");
+ return;
+ }
+ struct libinput_event_gesture *gevent =
+ libinput_event_get_gesture_event(event);
+ struct wlr_event_pointer_hold_end wlr_event = {
+ .device = wlr_dev,
+ .time_msec =
+ usec_to_msec(libinput_event_gesture_get_time_usec(gevent)),
+ .cancelled = libinput_event_gesture_get_cancelled(gevent),
+ };
+ wlr_signal_emit_safe(&wlr_dev->pointer->events.hold_end, &wlr_event);
+}
diff --git a/include/backend/libinput.h b/include/backend/libinput.h
index 06e23a17..e85ad291 100644
--- a/include/backend/libinput.h
+++ b/include/backend/libinput.h
@@ -66,6 +66,10 @@ 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);
+void handle_pointer_hold_begin(struct libinput_event *event,
+ struct libinput_device *device);
+void handle_pointer_hold_end(struct libinput_event *event,
+ struct libinput_device *device);
struct wlr_switch *create_libinput_switch(
struct libinput_device *device);