[clutter/wip/touchpad-gestures: 4/4] 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: 4/4] clutter-event: Add API around touchpad gesture events
- Date: Fri, 10 Jul 2015 16:17:20 +0000 (UTC)
commit 0a971bb7402a03bf8fe226deae8d9de23308897a
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 | 122 ++++++++++++++++++++++++++++++++++++
clutter/clutter-event.h | 17 +++++
doc/reference/clutter-sections.txt | 5 ++
3 files changed, 144 insertions(+), 0 deletions(-)
---
diff --git a/clutter/clutter-event.c b/clutter/clutter-event.c
index 3170b9d..5f86eb0 100644
--- a/clutter/clutter-event.c
+++ b/clutter/clutter-event.c
@@ -1877,3 +1877,125 @@ 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, 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, 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 at the time the corresponding event with phase
+ * %CLUTTER_TOUCHPAD_GESTURE_PHASE_BEGIN is received.
+ * is received.
+ *
+ * Returns: the current pinch gesture 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, 0);
+
+ return event->touchpad_pinch.scale;
+}
+
+/**
+ * clutter_event_get_gesture_phase:
+ * @event: a touchpad gesture event
+ *
+ * Returns the phase of the event, See #ClutterTouchpadGesturePhase.
+ *
+ * Returns: the phase of the gesture event.
+ **/
+ClutterTouchpadGesturePhase
+clutter_event_get_gesture_phase (const ClutterEvent *event)
+{
+ g_return_val_if_fail (event != NULL, 0);
+ g_return_val_if_fail (event->type == CLUTTER_TOUCHPAD_PINCH ||
+ event->type == CLUTTER_TOUCHPAD_SWIPE, 0);
+
+ if (event->type == CLUTTER_TOUCHPAD_PINCH)
+ return event->touchpad_pinch.phase;
+ else if (event->type == CLUTTER_TOUCHPAD_SWIPE)
+ return event->touchpad_swipe.phase;
+
+ /* Shouldn't ever happen */
+ return CLUTTER_TOUCHPAD_GESTURE_PHASE_BEGIN;
+};
+
+/**
+ * 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 ||
+ event->type == CLUTTER_TOUCHPAD_SWIPE, FALSE);
+
+ if (event->type == CLUTTER_TOUCHPAD_PINCH)
+ {
+ if (dx)
+ *dx = event->touchpad_pinch.dx;
+ if (dy)
+ *dy = event->touchpad_pinch.dy;
+ }
+ else if (event->type == CLUTTER_TOUCHPAD_SWIPE)
+ {
+ 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 e33b5c8..5b0b267 100644
--- a/clutter/clutter-event.h
+++ b/clutter/clutter-event.h
@@ -665,6 +665,23 @@ 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
+ClutterTouchpadGesturePhase clutter_event_get_gesture_phase (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 ccca66b..99e5ca7 100644
--- a/doc/reference/clutter-sections.txt
+++ b/doc/reference/clutter-sections.txt
@@ -1135,6 +1135,11 @@ 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_phase
+clutter_event_get_gesture_motion_delta
<SUBSECTION>
clutter_event_get
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]