[gtk+/wip/garnacho/touchpad-gestures: 54/71] gdk: Add touchpad gesture events and event types.
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/garnacho/touchpad-gestures: 54/71] gdk: Add touchpad gesture events and event types.
- Date: Fri, 24 Jul 2015 11:50:07 +0000 (UTC)
commit 875ffd2a707f829bb22adb5ec018df000cdcb089
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Jul 9 18:39:58 2015 +0200
gdk: Add touchpad gesture events and event types.
Each gesture type has its separate GdkEvent struct, and begin/update/
end/cancel event types.
There is support for multi-finger swipe (3-4 fingers), and 2-finger
rotate/pinch gestures.
docs/reference/gdk/gdk3-sections.txt | 2 +
gdk/gdkevents.c | 74 +++++++++++++++++++++++++++
gdk/gdkevents.h | 92 ++++++++++++++++++++++++++++++++++
3 files changed, 168 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt
index defd136..1aaefb5 100644
--- a/docs/reference/gdk/gdk3-sections.txt
+++ b/docs/reference/gdk/gdk3-sections.txt
@@ -883,6 +883,8 @@ GdkEventWindowState
GdkEventSetting
GdkEventOwnerChange
GdkEventGrabBroken
+GdkEventTouchpadSwipe
+GdkEventTouchpadPinch
<SUBSECTION>
GdkScrollDirection
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index b8b9554..c1b1498 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -570,6 +570,30 @@ gdk_event_new (GdkEventType type)
new_event->crossing.x_root = 0.;
new_event->crossing.y_root = 0.;
break;
+ case GDK_TOUCHPAD_SWIPE_BEGIN:
+ case GDK_TOUCHPAD_SWIPE_UPDATE:
+ case GDK_TOUCHPAD_SWIPE_END:
+ case GDK_TOUCHPAD_SWIPE_CANCEL:
+ new_event->touchpad_swipe.x = 0;
+ new_event->touchpad_swipe.y = 0;
+ new_event->touchpad_swipe.dx = 0;
+ new_event->touchpad_swipe.dy = 0;
+ new_event->touchpad_swipe.x_root = 0;
+ new_event->touchpad_swipe.y_root = 0;
+ break;
+ case GDK_TOUCHPAD_PINCH_BEGIN:
+ case GDK_TOUCHPAD_PINCH_UPDATE:
+ case GDK_TOUCHPAD_PINCH_END:
+ case GDK_TOUCHPAD_PINCH_CANCEL:
+ new_event->touchpad_pinch.x = 0;
+ new_event->touchpad_pinch.y = 0;
+ new_event->touchpad_pinch.dx = 0;
+ new_event->touchpad_pinch.dy = 0;
+ new_event->touchpad_pinch.angle_delta = 0;
+ new_event->touchpad_pinch.scale = 0;
+ new_event->touchpad_pinch.x_root = 0;
+ new_event->touchpad_pinch.y_root = 0;
+ break;
default:
break;
}
@@ -863,6 +887,16 @@ gdk_event_get_time (const GdkEvent *event)
case GDK_TOUCH_END:
case GDK_TOUCH_CANCEL:
return event->touch.time;
+ case GDK_TOUCHPAD_SWIPE_BEGIN:
+ case GDK_TOUCHPAD_SWIPE_UPDATE:
+ case GDK_TOUCHPAD_SWIPE_END:
+ case GDK_TOUCHPAD_SWIPE_CANCEL:
+ return event->touchpad_swipe.time;
+ case GDK_TOUCHPAD_PINCH_BEGIN:
+ case GDK_TOUCHPAD_PINCH_UPDATE:
+ case GDK_TOUCHPAD_PINCH_END:
+ case GDK_TOUCHPAD_PINCH_CANCEL:
+ return event->touchpad_pinch.time;
case GDK_SCROLL:
return event->scroll.time;
case GDK_KEY_PRESS:
@@ -946,6 +980,18 @@ gdk_event_get_state (const GdkEvent *event,
case GDK_TOUCH_CANCEL:
*state = event->touch.state;
return TRUE;
+ case GDK_TOUCHPAD_SWIPE_BEGIN:
+ case GDK_TOUCHPAD_SWIPE_UPDATE:
+ case GDK_TOUCHPAD_SWIPE_END:
+ case GDK_TOUCHPAD_SWIPE_CANCEL:
+ *state = event->touchpad_swipe.state;
+ return TRUE;
+ case GDK_TOUCHPAD_PINCH_BEGIN:
+ case GDK_TOUCHPAD_PINCH_UPDATE:
+ case GDK_TOUCHPAD_PINCH_END:
+ case GDK_TOUCHPAD_PINCH_CANCEL:
+ *state = event->touchpad_pinch.state;
+ return TRUE;
case GDK_SCROLL:
*state = event->scroll.state;
return TRUE;
@@ -1046,6 +1092,20 @@ gdk_event_get_coords (const GdkEvent *event,
x = event->motion.x;
y = event->motion.y;
break;
+ case GDK_TOUCHPAD_SWIPE_BEGIN:
+ case GDK_TOUCHPAD_SWIPE_UPDATE:
+ case GDK_TOUCHPAD_SWIPE_END:
+ case GDK_TOUCHPAD_SWIPE_CANCEL:
+ x = event->touchpad_swipe.x;
+ y = event->touchpad_swipe.y;
+ break;
+ case GDK_TOUCHPAD_PINCH_BEGIN:
+ case GDK_TOUCHPAD_PINCH_UPDATE:
+ case GDK_TOUCHPAD_PINCH_END:
+ case GDK_TOUCHPAD_PINCH_CANCEL:
+ x = event->touchpad_pinch.x;
+ y = event->touchpad_pinch.y;
+ break;
default:
fetched = FALSE;
break;
@@ -1117,6 +1177,20 @@ gdk_event_get_root_coords (const GdkEvent *event,
x = event->dnd.x_root;
y = event->dnd.y_root;
break;
+ case GDK_TOUCHPAD_SWIPE_BEGIN:
+ case GDK_TOUCHPAD_SWIPE_UPDATE:
+ case GDK_TOUCHPAD_SWIPE_END:
+ case GDK_TOUCHPAD_SWIPE_CANCEL:
+ x = event->touchpad_swipe.x_root;
+ y = event->touchpad_swipe.y_root;
+ break;
+ case GDK_TOUCHPAD_PINCH_BEGIN:
+ case GDK_TOUCHPAD_PINCH_UPDATE:
+ case GDK_TOUCHPAD_PINCH_END:
+ case GDK_TOUCHPAD_PINCH_CANCEL:
+ x = event->touchpad_pinch.x_root;
+ y = event->touchpad_pinch.y_root;
+ break;
default:
fetched = FALSE;
break;
diff --git a/gdk/gdkevents.h b/gdk/gdkevents.h
index d681de7..9b0ae79 100644
--- a/gdk/gdkevents.h
+++ b/gdk/gdkevents.h
@@ -139,6 +139,8 @@ typedef struct _GdkEventDND GdkEventDND;
typedef struct _GdkEventWindowState GdkEventWindowState;
typedef struct _GdkEventSetting GdkEventSetting;
typedef struct _GdkEventGrabBroken GdkEventGrabBroken;
+typedef struct _GdkEventTouchpadSwipe GdkEventTouchpadSwipe;
+typedef struct _GdkEventTouchpadPinch GdkEventTouchpadPinch;
typedef struct _GdkEventSequence GdkEventSequence;
@@ -331,6 +333,14 @@ typedef enum
GDK_TOUCH_UPDATE = 38,
GDK_TOUCH_END = 39,
GDK_TOUCH_CANCEL = 40,
+ GDK_TOUCHPAD_SWIPE_BEGIN = 41,
+ GDK_TOUCHPAD_SWIPE_UPDATE = 42,
+ GDK_TOUCHPAD_SWIPE_END = 43,
+ GDK_TOUCHPAD_SWIPE_CANCEL = 44,
+ GDK_TOUCHPAD_PINCH_BEGIN = 45,
+ GDK_TOUCHPAD_PINCH_UPDATE = 46,
+ GDK_TOUCHPAD_PINCH_END = 47,
+ GDK_TOUCHPAD_PINCH_CANCEL = 48,
GDK_EVENT_LAST /* helper variable for decls */
} GdkEventType;
@@ -1114,6 +1124,86 @@ struct _GdkEventDND {
};
/**
+ * GdkEventTouchpadSwipe:
+ * @type: the type of the event (%GDK_TOUCHPAD_SWIPE_BEGIN,
+ * %GDK_TOUCHPAD_SWIPE_UPDATE, %GDK_TOUCHPAD_SWIPE_END or
+ * %GDK_TOUCHPAD_SWIPE_CANCEL).
+ * @window: the window which received the event
+ * @send_event: %TRUE if the event was sent explicitly
+ * @n_fingers: The number of fingers triggering the swipe
+ * @time: the time of the event in milliseconds
+ * @x: The X coordinate of the pointer
+ * @y: The Y coordinate of the pointer
+ * @dx: Movement delta in the X axis of the swipe focal point
+ * @dy: Movement delta in the Y axis of the swipe focal point
+ * @x_root: The X coordinate of the pointer, relative to the
+ * root of the screen.
+ * @y_root: The Y coordinate of the pointer, relative to the
+ * root of the screen.
+ * @state: (type GdkModifierType): a bit-mask representing the state of
+ * the modifier keys (e.g. Control, Shift and Alt) and the pointer
+ * buttons. See #GdkModifierType.
+ *
+ * Generated during touchpad swipe gestures.
+ */
+struct _GdkEventTouchpadSwipe {
+ GdkEventType type;
+ GdkWindow *window;
+ gint8 send_event;
+ gint8 n_fingers;
+ guint32 time;
+ gdouble x;
+ gdouble y;
+ gdouble dx;
+ gdouble dy;
+ gdouble x_root, y_root;
+ guint state;
+};
+
+/**
+ * GdkEventTouchpadPinch:
+ * @type: the type of the event (%GDK_TOUCHPAD_PINCH_BEGIN,
+ * %GDK_TOUCHPAD_PINCH_UPDATE, %GDK_TOUCHPAD_PINCH_END or
+ * %GDK_TOUCHPAD_PINCH_CANCEL).
+ * @window: the window which received the event
+ * @send_event: %TRUE if the event was sent explicitly
+ * @n_fingers: The number of fingers triggering the pinch
+ * @time: the time of the event in milliseconds
+ * @x: The X coordinate of the pointer
+ * @y: The Y coordinate of the pointer
+ * @dx: Movement delta in the X axis of the swipe focal point
+ * @dy: Movement delta in the Y axis of the swipe focal point
+ * @angle_delta: The angle change in degrees, negative angles
+ * denote counter-clockwise movements
+ * @scale: The current scale, relative to that at the time of
+ * the corresponding %GDK_TOUCHPAD_PINCH_BEGIN event
+ * @x_root: The X coordinate of the pointer, relative to the
+ * root of the screen.
+ * @y_root: The Y coordinate of the pointer, relative to the
+ * root of the screen.
+ * @state: (type GdkModifierType): a bit-mask representing the state of
+ * the modifier keys (e.g. Control, Shift and Alt) and the pointer
+ * buttons. See #GdkModifierType.
+ *
+ * Generated during touchpad swipe gestures.
+ */
+struct _GdkEventTouchpadPinch {
+ GdkEventType type;
+ GdkWindow *window;
+ gint8 send_event;
+ gint8 n_fingers;
+ guint32 time;
+ gdouble x;
+ gdouble y;
+ gdouble dx;
+ gdouble dy;
+ gdouble angle_delta;
+ gdouble scale;
+ gdouble x_root, y_root;
+ guint state;
+};
+
+/**
* GdkEvent:
* @type: the #GdkEventType
* @any: a #GdkEventAny
@@ -1189,6 +1279,8 @@ union _GdkEvent
GdkEventWindowState window_state;
GdkEventSetting setting;
GdkEventGrabBroken grab_broken;
+ GdkEventTouchpadSwipe touchpad_swipe;
+ GdkEventTouchpadPinch touchpad_pinch;
};
GDK_AVAILABLE_IN_ALL
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]