Extend the touchpad gesture API with pinch gestures. Note that this
new API offers a single event stream for both pinch and rotate data, this
is deliberate as some applications may be interested in getting both at
the same time. Applications which are only interested in one or the other
can simply ignore the other.
Signed-off-by: Hans de Goede <[email protected]>
---
src/libinput-private.h | 12 +++++++++
src/libinput.c | 51 +++++++++++++++++++++++++++++++++++--
src/libinput.h | 68 ++++++++++++++++++++++++++++++++++++++++++--------
src/libinput.sym | 2 ++
test/litest.c | 9 +++++++
tools/event-debug.c | 27 +++++++++++++++++++-
6 files changed, 156 insertions(+), 13 deletions(-)
diff --git a/src/libinput-private.h b/src/libinput-private.h
index 86d1636..c0847bd 100644
--- a/src/libinput-private.h
+++ b/src/libinput-private.h
@@ -330,6 +330,18 @@ touch_notify_touch_up(struct libinput_device *device,
int32_t seat_slot);
void
+gesture_notify_pinch(struct libinput_device *device,
+ uint64_t time,
+ enum libinput_event_type type,
+ int finger_count,
+ double dx,
+ double dy,
+ double dx_unaccel,
+ double dy_unaccel,
+ double distance,
+ double angle);
+
+void
gesture_notify_swipe(struct libinput_device *device,
uint64_t time,
enum libinput_event_type type,
diff --git a/src/libinput.c b/src/libinput.c
index f49e7fe..5fb0c65 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -87,6 +87,8 @@ struct libinput_event_gesture {
double dy;
double dx_unaccel;
double dy_unaccel;
+ double distance;
+ double angle;
};
static void
@@ -196,6 +198,9 @@ libinput_event_get_pointer_event(struct libinput_event
*event)
case LIBINPUT_EVENT_GESTURE_SWIPE_START:
case LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE:
case LIBINPUT_EVENT_GESTURE_SWIPE_END:
+ case LIBINPUT_EVENT_GESTURE_PINCH_START:
+ case LIBINPUT_EVENT_GESTURE_PINCH_UPDATE:
+ case LIBINPUT_EVENT_GESTURE_PINCH_END:
break;
}
@@ -226,6 +231,9 @@ libinput_event_get_keyboard_event(struct libinput_event
*event)
case LIBINPUT_EVENT_GESTURE_SWIPE_START:
case LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE:
case LIBINPUT_EVENT_GESTURE_SWIPE_END:
+ case LIBINPUT_EVENT_GESTURE_PINCH_START:
+ case LIBINPUT_EVENT_GESTURE_PINCH_UPDATE:
+ case LIBINPUT_EVENT_GESTURE_PINCH_END:
break;
}
@@ -255,6 +263,9 @@ libinput_event_get_touch_event(struct libinput_event *event)
case LIBINPUT_EVENT_GESTURE_SWIPE_START:
case LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE:
case LIBINPUT_EVENT_GESTURE_SWIPE_END:
+ case LIBINPUT_EVENT_GESTURE_PINCH_START:
+ case LIBINPUT_EVENT_GESTURE_PINCH_UPDATE:
+ case LIBINPUT_EVENT_GESTURE_PINCH_END:
break;
}
@@ -285,6 +296,9 @@ libinput_event_get_gesture_event(struct libinput_event
*event)
case LIBINPUT_EVENT_GESTURE_SWIPE_START:
case LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE:
case LIBINPUT_EVENT_GESTURE_SWIPE_END:
+ case LIBINPUT_EVENT_GESTURE_PINCH_START:
+ case LIBINPUT_EVENT_GESTURE_PINCH_UPDATE:
+ case LIBINPUT_EVENT_GESTURE_PINCH_END:
return (struct libinput_event_gesture *) event;
}
@@ -314,6 +328,9 @@ libinput_event_get_device_notify_event(struct
libinput_event *event)
case LIBINPUT_EVENT_GESTURE_SWIPE_START:
case LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE:
case LIBINPUT_EVENT_GESTURE_SWIPE_END:
+ case LIBINPUT_EVENT_GESTURE_PINCH_START:
+ case LIBINPUT_EVENT_GESTURE_PINCH_UPDATE:
+ case LIBINPUT_EVENT_GESTURE_PINCH_END:
break;
}
@@ -595,6 +612,18 @@ libinput_event_gesture_get_dy_unaccelerated(
return event->dy_unaccel;
}
+LIBINPUT_EXPORT double
+libinput_event_gesture_get_distance(struct libinput_event_gesture *event)
+{
+ return event->distance;
+}
+
+LIBINPUT_EXPORT double
+libinput_event_gesture_get_angle(struct libinput_event_gesture *event)
+{
+ return event->angle;
+}
+
struct libinput_source *
libinput_add_fd(struct libinput *libinput,
int fd,
@@ -1257,14 +1286,16 @@ touch_notify_frame(struct libinput_device *device,
}
void
-gesture_notify_swipe(struct libinput_device *device,
+gesture_notify_pinch(struct libinput_device *device,
uint64_t time,
enum libinput_event_type type,
int finger_count,
double dx,
double dy,
double dx_unaccel,
- double dy_unaccel)
+ double dy_unaccel,
+ double distance,
+ double angle)
{
struct libinput_event_gesture *gesture_event;
@@ -1279,12 +1310,28 @@ gesture_notify_swipe(struct libinput_device *device,
.dy = dy,
.dx_unaccel = dx_unaccel,
.dy_unaccel = dy_unaccel,
+ .distance = distance,
+ .angle = angle,
};
post_device_event(device, time, type,
&gesture_event->base);
}
+void
+gesture_notify_swipe(struct libinput_device *device,
+ uint64_t time,
+ enum libinput_event_type type,
+ int finger_count,
+ double dx,
+ double dy,
+ double dx_unaccel,
+ double dy_unaccel)
+{
+ gesture_notify_pinch(device, time, type, finger_count,
+ dx, dy, dx_unaccel, dy_unaccel, 0.0, 0.0);
+}
+