aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorGreg V <greg@unrelenting.technology>2019-01-26 01:51:38 +0300
committeremersion <contact@emersion.fr>2019-01-28 22:06:36 +0100
commit9fe8e379613c42338920e913c6ffd6d1c273da67 (patch)
tree51937a7d4827b20ffe27783e9b4ae26bdf7175f0 /backend
parent018727b1fc41dcd739ab464c84581c44dd1497ca (diff)
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).
Diffstat (limited to 'backend')
-rw-r--r--backend/libinput/events.c18
-rw-r--r--backend/libinput/pointer.c120
2 files changed, 138 insertions, 0 deletions
diff --git a/backend/libinput/events.c b/backend/libinput/events.c
index a7a6c114..93f8c527 100644
--- a/backend/libinput/events.c
+++ b/backend/libinput/events.c
@@ -287,6 +287,24 @@ void handle_libinput_event(struct wlr_libinput_backend *backend,
case LIBINPUT_EVENT_SWITCH_TOGGLE:
handle_switch_toggle(event, libinput_dev);
break;
+ case LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN:
+ handle_pointer_swipe_begin(event, libinput_dev);
+ break;
+ case LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE:
+ handle_pointer_swipe_update(event, libinput_dev);
+ break;
+ case LIBINPUT_EVENT_GESTURE_SWIPE_END:
+ handle_pointer_swipe_end(event, libinput_dev);
+ break;
+ case LIBINPUT_EVENT_GESTURE_PINCH_BEGIN:
+ handle_pointer_pinch_begin(event, libinput_dev);
+ break;
+ case LIBINPUT_EVENT_GESTURE_PINCH_UPDATE:
+ handle_pointer_pinch_update(event, libinput_dev);
+ break;
+ case LIBINPUT_EVENT_GESTURE_PINCH_END:
+ handle_pointer_pinch_end(event, libinput_dev);
+ break;
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 0df16a10..2e799df6 100644
--- a/backend/libinput/pointer.c
+++ b/backend/libinput/pointer.c
@@ -140,3 +140,123 @@ void handle_pointer_axis(struct libinput_event *event,
}
wlr_signal_emit_safe(&wlr_dev->pointer->events.frame, wlr_dev->pointer);
}
+
+void handle_pointer_swipe_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_swipe_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.swipe_begin, &wlr_event);
+}
+
+void handle_pointer_swipe_update(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_swipe_update 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),
+ .dx = libinput_event_gesture_get_dx(gevent),
+ .dy = libinput_event_gesture_get_dy(gevent),
+ };
+ wlr_signal_emit_safe(&wlr_dev->pointer->events.swipe_update, &wlr_event);
+}
+
+void handle_pointer_swipe_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_swipe_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.swipe_end, &wlr_event);
+}
+
+void handle_pointer_pinch_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_pinch_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.pinch_begin, &wlr_event);
+}
+
+void handle_pointer_pinch_update(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_pinch_update 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),
+ .dx = libinput_event_gesture_get_dx(gevent),
+ .dy = libinput_event_gesture_get_dy(gevent),
+ .scale = libinput_event_gesture_get_scale(gevent),
+ .rotation = libinput_event_gesture_get_angle_delta(gevent),
+ };
+ wlr_signal_emit_safe(&wlr_dev->pointer->events.pinch_update, &wlr_event);
+}
+
+void handle_pointer_pinch_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_pinch_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.pinch_end, &wlr_event);
+}