diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2011-03-11 21:01:30 +0100 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2011-03-11 23:33:14 +0100 |
commit | be5f2c7cd4dd97a12b8a26945f052326548179c7 (patch) | |
tree | b0d4d9e951806be3d1543b5ebc8a302892396148 | |
parent | 776477ee9628e5bc9317197b432704dcf0781a3b (diff) | |
download | gtk+-be5f2c7cd4dd97a12b8a26945f052326548179c7.tar.gz |
Define GdkEventMultiTouch and its related event types.
This event will gather all touches within a GdkTouchCluster,
including an array of the latest GDK_TOUCH_MOTION events for
the touch IDs contained in there.
-rw-r--r-- | docs/reference/gdk/gdk3-sections.txt | 1 | ||||
-rw-r--r-- | gdk/gdkevents.c | 50 | ||||
-rw-r--r-- | gdk/gdkevents.h | 58 |
3 files changed, 109 insertions, 0 deletions
diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt index 00c6fa0e7d..e33262b335 100644 --- a/docs/reference/gdk/gdk3-sections.txt +++ b/docs/reference/gdk/gdk3-sections.txt @@ -818,6 +818,7 @@ GdkEventWindowState GdkEventSetting GdkEventOwnerChange GdkEventGrabBroken +GdkEventMultiTouch <SUBSECTION> GdkScrollDirection diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c index 53c83a5d5f..96db366b31 100644 --- a/gdk/gdkevents.c +++ b/gdk/gdkevents.c @@ -589,6 +589,22 @@ gdk_event_copy (const GdkEvent *event) g_object_unref (new_event->selection.requestor); break; + case GDK_MULTITOUCH_ADDED: + case GDK_MULTITOUCH_REMOVED: + case GDK_MULTITOUCH_UPDATED: + { + GdkEventMotion **motion_events; + guint i; + + motion_events = g_new0 (GdkEventMotion*, event->multitouch.n_events); + + for (i = 0; i < event->multitouch.n_events; i++) + motion_events[i] = (GdkEventMotion *) gdk_event_copy ((GdkEvent *) event->multitouch.events[i]); + + new_event->multitouch.events = motion_events; + } + break; + default: break; } @@ -675,6 +691,20 @@ gdk_event_free (GdkEvent *event) g_object_unref (event->selection.requestor); break; + case GDK_MULTITOUCH_ADDED: + case GDK_MULTITOUCH_REMOVED: + case GDK_MULTITOUCH_UPDATED: + if (event->multitouch.events) + { + guint i; + + for (i = 0; i < event->multitouch.n_events; i++) + gdk_event_free ((GdkEvent *) event->multitouch.events[i]); + + g_free (event->multitouch.events); + } + break; + default: break; } @@ -734,6 +764,10 @@ gdk_event_get_time (const GdkEvent *event) case GDK_DROP_START: case GDK_DROP_FINISHED: return event->dnd.time; + case GDK_MULTITOUCH_ADDED: + case GDK_MULTITOUCH_REMOVED: + case GDK_MULTITOUCH_UPDATED: + return event->multitouch.time; case GDK_CLIENT_EVENT: case GDK_VISIBILITY_NOTIFY: case GDK_CONFIGURE: @@ -801,6 +835,11 @@ gdk_event_get_state (const GdkEvent *event, case GDK_LEAVE_NOTIFY: *state = event->crossing.state; return TRUE; + case GDK_MULTITOUCH_ADDED: + case GDK_MULTITOUCH_REMOVED: + case GDK_MULTITOUCH_UPDATED: + *state = event->multitouch.state; + return TRUE; case GDK_PROPERTY_NOTIFY: case GDK_VISIBILITY_NOTIFY: case GDK_CLIENT_EVENT: @@ -1090,6 +1129,10 @@ gdk_event_set_device (GdkEvent *event, case GDK_PROXIMITY_OUT: event->proximity.device = device; break; + case GDK_MULTITOUCH_ADDED: + case GDK_MULTITOUCH_REMOVED: + case GDK_MULTITOUCH_UPDATED: + event->multitouch.device = device; default: break; } @@ -1136,6 +1179,10 @@ gdk_event_get_device (const GdkEvent *event) case GDK_PROXIMITY_IN: case GDK_PROXIMITY_OUT: return event->proximity.device; + case GDK_MULTITOUCH_ADDED: + case GDK_MULTITOUCH_REMOVED: + case GDK_MULTITOUCH_UPDATED: + return event->multitouch.device; default: break; } @@ -1166,6 +1213,9 @@ gdk_event_get_device (const GdkEvent *event) case GDK_GRAB_BROKEN: case GDK_KEY_PRESS: case GDK_KEY_RELEASE: + case GDK_MULTITOUCH_ADDED: + case GDK_MULTITOUCH_REMOVED: + case GDK_MULTITOUCH_UPDATED: { GdkDisplay *display; GdkDeviceManager *device_manager; diff --git a/gdk/gdkevents.h b/gdk/gdkevents.h index d03e4f07d0..53e64570a8 100644 --- a/gdk/gdkevents.h +++ b/gdk/gdkevents.h @@ -35,6 +35,7 @@ #include <gdk/gdktypes.h> #include <gdk/gdkdnd.h> #include <gdk/gdkdevice.h> +#include <gdk/gdktouchcluster.h> G_BEGIN_DECLS @@ -93,6 +94,7 @@ typedef struct _GdkEventDND GdkEventDND; typedef struct _GdkEventWindowState GdkEventWindowState; typedef struct _GdkEventSetting GdkEventSetting; typedef struct _GdkEventGrabBroken GdkEventGrabBroken; +typedef struct _GdkEventMultiTouch GdkEventMultiTouch; typedef union _GdkEvent GdkEvent; @@ -216,6 +218,9 @@ typedef GdkFilterReturn (*GdkFilterFunc) (GdkXEvent *xevent, * @GDK_TOUCH_MOTION: A touch device has been updated. * @GDK_TOUCH_PRESS: A new touch stream has just started. * @GDK_TOUCH_RELEASE: A touch stream has finished. + * @GDK_MULTITOUCH_ADDED: A touch ID was added to a #GdkTouchCluster + * @GDK_MULTITOUCH_UPDATED: A touch within a #GdkTouchCluster has been updated. + * @GDK_MULTITOUCH_REMOVED: A touch ID was removed from a #GdkTouchCluster. * @GDK_EVENT_LAST: marks the end of the GdkEventType enumeration. Added in 2.18 * * Specifies the type of the event. @@ -266,6 +271,9 @@ typedef enum GDK_TOUCH_MOTION = 37, GDK_TOUCH_PRESS = 38, GDK_TOUCH_RELEASE = 39, + GDK_MULTITOUCH_ADDED = 40, + GDK_MULTITOUCH_UPDATED = 41, + GDK_MULTITOUCH_REMOVED = 42, GDK_EVENT_LAST /* helper variable for decls */ } GdkEventType; @@ -527,6 +535,55 @@ struct _GdkEventMotion }; /** + * GdkEventMultiTouch: + * @type: the type of the event (%GDK_MULTITOUCH_ADDED, %GDK_MULTITOUCH_UPDATED + * or %GDK_MULTITOUCH_REMOVED). + * @window: the window which received the event. + * @send_event: %TRUE if the event was sent explicitly (e.g. using + * <function>XSendEvent</function>). + * @time: the time of the event in milliseconds. + * @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. + * @device: the device where the event originated. + * @group: the #GdkTouchCluster containing the touches that generated this event + * @events: an array of events of type %GDK_TOUCH_MOTION for the touches in @group + * @updated_touch_id: the touch ID that caused this event to be generated + * @n_events: the number of events in @events + * @n_updated_event: the index in @events of the event corresponding to + * @updated_touch_id, or -1 for %GDK_MULTITOUCH_REMOVED events. + * + * Used for multitouch events. The @type field will be one of + * %GDK_MULTITOUCH_ADDED, %GDK_MULTITOUCH_UPDATED or + * %GDK_MULTITOUCH_REMOVED. + * + * Multitouch events group the events from the touches in a + * #GdkTouchCluster, so one of these events is generated + * whenever a touch ID generates a new event, or a touch ID + * is added or removed. + * + * For any given touch ID, %GDK_MULTITOUCH_ADDED and + * %GDK_MULTITOUCH_REMOVED events are always paired, + * with any number of %GDK_MULTITOUCH_UPDATED + * events in between. The minimum event stream is an + * added/removed pair. + */ +struct _GdkEventMultiTouch +{ + GdkEventType type; + GdkWindow *window; + gint8 send_event; + guint32 time; + guint state; + GdkDevice *device; + GdkTouchCluster *group; + GdkEventMotion **events; + guint updated_touch_id; + gint8 n_events; + gint8 n_updated_event; +}; + +/** * GdkEventButton: * @type: the type of the event (%GDK_BUTTON_PRESS, %GDK_2BUTTON_PRESS, * %GDK_3BUTTON_PRESS or %GDK_BUTTON_RELEASE). @@ -1045,6 +1102,7 @@ union _GdkEvent GdkEventWindowState window_state; GdkEventSetting setting; GdkEventGrabBroken grab_broken; + GdkEventMultiTouch multitouch; }; GType gdk_event_get_type (void) G_GNUC_CONST; |