[gtk+/multitouch: 10/33] Define GdkEventMultiTouch and its related event types.



commit a55329f82b2ea6ba0d4d897ae6d8462314253373
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Mar 11 21:01:30 2011 +0100

    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.

 docs/reference/gdk/gdk3-sections.txt |    1 +
 gdk/gdkevents.c                      |   50 +++++++++++++++++++++++++++++
 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 f8fa7d7..5ba6531 100644
--- a/docs/reference/gdk/gdk3-sections.txt
+++ b/docs/reference/gdk/gdk3-sections.txt
@@ -830,6 +830,7 @@ GdkEventWindowState
 GdkEventSetting
 GdkEventOwnerChange
 GdkEventGrabBroken
+GdkEventMultiTouch
 
 <SUBSECTION>
 GdkScrollDirection
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index dd21942..978323b 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -589,6 +589,22 @@ gdk_event_copy (const GdkEvent *event)
         g_object_ref (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;
     }
@@ -677,6 +693,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;
     }
@@ -738,6 +768,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:
@@ -805,6 +839,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:
@@ -1280,6 +1319,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;
     }
@@ -1326,6 +1369,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;
     }
@@ -1356,6 +1403,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 c4dac90..ce54e7d 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;
 
@@ -541,6 +549,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).
@@ -1059,6 +1116,7 @@ union _GdkEvent
   GdkEventWindowState       window_state;
   GdkEventSetting           setting;
   GdkEventGrabBroken        grab_broken;
+  GdkEventMultiTouch        multitouch;
 };
 
 GType     gdk_event_get_type            (void) G_GNUC_CONST;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]