[clutter/wip/touchpad-gestures: 16/16] clutter-event: Add API around touchpad gesture events
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/wip/touchpad-gestures: 16/16] clutter-event: Add API around touchpad gesture events
- Date: Thu, 9 Jul 2015 10:16:19 +0000 (UTC)
commit 5a146e494738b10287b23f6199715229663398b5
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Jul 1 15:15:41 2015 +0200
clutter-event: Add API around touchpad gesture events
These are needed in order to make these events binding friendly
clutter/clutter-event.c | 117 ++++++++++++++++++++++++++++++++++++
clutter/clutter-event.h | 14 ++++
doc/reference/clutter-sections.txt | 4 +
3 files changed, 135 insertions(+), 0 deletions(-)
---
diff --git a/clutter/clutter-event.c b/clutter/clutter-event.c
index 7a53896..31a429c 100644
--- a/clutter/clutter-event.c
+++ b/clutter/clutter-event.c
@@ -1907,3 +1907,120 @@ clutter_event_remove_filter (guint id)
g_warning ("No event filter found for id: %d\n", id);
}
+
+/**
+ * clutter_event_get_gesture_swipe_finger_count:
+ * @event: a touchpad swipe event
+ *
+ * Returns the number of fingers that is triggering the touchpad gesture.
+ *
+ * Returns: the number of fingers swiping.
+ *
+ * Since: 1.24
+ **/
+guint
+clutter_event_get_gesture_swipe_finger_count (const ClutterEvent *event)
+{
+ g_return_val_if_fail (event != NULL, 0);
+ g_return_val_if_fail (event->type == CLUTTER_TOUCHPAD_SWIPE_BEGIN ||
+ event->type == CLUTTER_TOUCHPAD_SWIPE_UPDATE ||
+ event->type == CLUTTER_TOUCHPAD_SWIPE_END ||
+ event->type == CLUTTER_TOUCHPAD_SWIPE_CANCEL, 0);
+
+ return event->touchpad_swipe.n_fingers;
+}
+
+/**
+ * clutter_event_get_gesture_pinch_angle_delta:
+ * @event: a touchpad pinch event
+ *
+ * Returns the angle delta reported by this specific event.
+ *
+ * Returns: The angle delta relative to the previous event.
+ *
+ * Since: 1.24
+ **/
+gdouble
+clutter_event_get_gesture_pinch_angle_delta (const ClutterEvent *event)
+{
+ g_return_val_if_fail (event != NULL, 0);
+ g_return_val_if_fail (event->type == CLUTTER_TOUCHPAD_PINCH_BEGIN ||
+ event->type == CLUTTER_TOUCHPAD_PINCH_UPDATE ||
+ event->type == CLUTTER_TOUCHPAD_PINCH_END ||
+ event->type == CLUTTER_TOUCHPAD_PINCH_CANCEL, 0);
+
+ return event->touchpad_pinch.angle_delta;
+}
+
+/**
+ * clutter_event_get_gesture_pinch_scale:
+ * @event: a touchpad pinch event
+ *
+ * Returns the current scale as reported by @event, 1.0 being the original
+ * distance as reported in the %CLUTTER_TOUCHPAD_PINCH_BEGIN event
+ *
+ * Returns: the pinch gesture current scale
+ *
+ * Since: 1.24
+ **/
+gdouble
+clutter_event_get_gesture_pinch_scale (const ClutterEvent *event)
+{
+ g_return_val_if_fail (event != NULL, 0);
+ g_return_val_if_fail (event->type == CLUTTER_TOUCHPAD_PINCH_BEGIN ||
+ event->type == CLUTTER_TOUCHPAD_PINCH_UPDATE ||
+ event->type == CLUTTER_TOUCHPAD_PINCH_END ||
+ event->type == CLUTTER_TOUCHPAD_PINCH_CANCEL, 0);
+
+ return event->touchpad_pinch.scale;
+}
+
+/**
+ * clutter_event_get_gesture_motion_delta:
+ * @event: A clutter touchpad gesture event
+ * @dx: (out) (allow-none): the displacement relative to the pointer
+ * position in the X axis, or %NULL
+ * @dy: (out) (allow-none): the displacement relative to the pointer
+ * position in the Y axis, or %NULL
+ *
+ * Returns the gesture motion deltas relative to the current pointer
+ * position.
+ *
+ * Since: 1.24
+ **/
+void
+clutter_event_get_gesture_motion_delta (const ClutterEvent *event,
+ gdouble *dx,
+ gdouble *dy)
+{
+ g_return_val_if_fail (event != NULL, FALSE);
+ g_return_val_if_fail (event->type == CLUTTER_TOUCHPAD_PINCH_BEGIN ||
+ event->type == CLUTTER_TOUCHPAD_PINCH_UPDATE ||
+ event->type == CLUTTER_TOUCHPAD_PINCH_END ||
+ event->type == CLUTTER_TOUCHPAD_PINCH_CANCEL ||
+ event->type == CLUTTER_TOUCHPAD_SWIPE_BEGIN ||
+ event->type == CLUTTER_TOUCHPAD_SWIPE_UPDATE ||
+ event->type == CLUTTER_TOUCHPAD_SWIPE_END ||
+ event->type == CLUTTER_TOUCHPAD_SWIPE_CANCEL, FALSE);
+
+ if (event->type == CLUTTER_TOUCHPAD_PINCH_BEGIN ||
+ event->type == CLUTTER_TOUCHPAD_PINCH_UPDATE ||
+ event->type == CLUTTER_TOUCHPAD_PINCH_END ||
+ event->type == CLUTTER_TOUCHPAD_PINCH_CANCEL)
+ {
+ if (dx)
+ *dx = event->touchpad_pinch.dx;
+ if (dy)
+ *dy = event->touchpad_pinch.dy;
+ }
+ else if (event->type == CLUTTER_TOUCHPAD_SWIPE_BEGIN ||
+ event->type == CLUTTER_TOUCHPAD_SWIPE_UPDATE ||
+ event->type == CLUTTER_TOUCHPAD_SWIPE_END ||
+ event->type == CLUTTER_TOUCHPAD_SWIPE_CANCEL)
+ {
+ if (dx)
+ *dx = event->touchpad_swipe.dx;
+ if (dy)
+ *dy = event->touchpad_swipe.dy;
+ }
+}
diff --git a/clutter/clutter-event.h b/clutter/clutter-event.h
index f1a032e..db0ea5a 100644
--- a/clutter/clutter-event.h
+++ b/clutter/clutter-event.h
@@ -618,6 +618,20 @@ guint32 clutter_get_current_event_time (void);
CLUTTER_AVAILABLE_IN_1_2
const ClutterEvent * clutter_get_current_event (void);
+CLUTTER_AVAILABLE_IN_1_24
+guint clutter_event_get_gesture_swipe_finger_count (const ClutterEvent *event);
+
+CLUTTER_AVAILABLE_IN_1_24
+gdouble clutter_event_get_gesture_pinch_angle_delta (const ClutterEvent *event);
+
+CLUTTER_AVAILABLE_IN_1_24
+gdouble clutter_event_get_gesture_pinch_scale (const ClutterEvent *event);
+
+CLUTTER_AVAILABLE_IN_1_24
+void clutter_event_get_gesture_motion_delta (const ClutterEvent *event,
+ gdouble *dx,
+ gdouble *dy);
+
G_END_DECLS
#endif /* __CLUTTER_EVENT_H__ */
diff --git a/doc/reference/clutter-sections.txt b/doc/reference/clutter-sections.txt
index da89958..0c5e359 100644
--- a/doc/reference/clutter-sections.txt
+++ b/doc/reference/clutter-sections.txt
@@ -1133,6 +1133,10 @@ clutter_event_get_position
clutter_event_has_control_modifier
clutter_event_has_shift_modifier
clutter_event_is_pointer_emulated
+clutter_event_get_gesture_swipe_finger_count
+clutter_event_get_gesture_pinch_angle_delta
+clutter_event_get_gesture_pinch_scale
+clutter_event_get_gesture_motion_delta
<SUBSECTION>
clutter_event_get
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]