[gtk+/multitouch: 3/40] Add touch motion event type and mask.



commit 7d4b6fe66caafdbb8a1ec6bc4303f265bce72b7a
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Feb 28 20:53:42 2011 +0100

    Add touch motion event type and mask.
    
    These events' struct is the same than GdkEventMotion, which has been
    added a touch_id parameter. The gdk_event_* functions have been modified
    to also handle this event type.

 gdk/gdkevents.c |   16 ++++++++++++++--
 gdk/gdkevents.h |    6 +++++-
 gdk/gdktypes.h  |    4 +++-
 3 files changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index 7a5e4c3..065f13b 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -445,6 +445,7 @@ gdk_event_new (GdkEventType type)
   switch (type)
     {
     case GDK_MOTION_NOTIFY:
+    case GDK_TOUCH_MOTION:
       new_event->motion.x = 0.;
       new_event->motion.y = 0.;
       new_event->motion.x_root = 0.;
@@ -564,6 +565,7 @@ gdk_event_copy (const GdkEvent *event)
       break;
 
     case GDK_MOTION_NOTIFY:
+    case GDK_TOUCH_MOTION:
       if (event->motion.axes)
         new_event->motion.axes = g_memdup (event->motion.axes,
                                            sizeof (gdouble) * gdk_device_get_n_axes (event->motion.device));
@@ -649,6 +651,7 @@ gdk_event_free (GdkEvent *event)
       break;
       
     case GDK_MOTION_NOTIFY:
+    case GDK_TOUCH_MOTION:
       g_free (event->motion.axes);
       break;
       
@@ -696,6 +699,7 @@ gdk_event_get_time (const GdkEvent *event)
     switch (event->type)
       {
       case GDK_MOTION_NOTIFY:
+      case GDK_TOUCH_MOTION:
 	return event->motion.time;
       case GDK_BUTTON_PRESS:
       case GDK_2BUTTON_PRESS:
@@ -771,6 +775,7 @@ gdk_event_get_state (const GdkEvent        *event,
     switch (event->type)
       {
       case GDK_MOTION_NOTIFY:
+      case GDK_TOUCH_MOTION:
 	*state = event->motion.state;
         return TRUE;
       case GDK_BUTTON_PRESS:
@@ -869,6 +874,7 @@ gdk_event_get_coords (const GdkEvent *event,
       y = event->button.y;
       break;
     case GDK_MOTION_NOTIFY:
+    case GDK_TOUCH_MOTION:
       x = event->motion.x;
       y = event->motion.y;
       break;
@@ -908,6 +914,7 @@ gdk_event_get_root_coords (const GdkEvent *event,
   switch (event->type)
     {
     case GDK_MOTION_NOTIFY:
+    case GDK_TOUCH_MOTION:
       x = event->motion.x_root;
       y = event->motion.y_root;
       break;
@@ -1162,7 +1169,8 @@ gdk_event_get_axis (const GdkEvent *event,
       
       switch (event->type)
 	{
-	case GDK_MOTION_NOTIFY:
+        case GDK_MOTION_NOTIFY:
+        case GDK_TOUCH_MOTION:
 	  x = event->motion.x;
 	  y = event->motion.y;
 	  break;
@@ -1198,7 +1206,8 @@ gdk_event_get_axis (const GdkEvent *event,
       device = event->button.device;
       axes = event->button.axes;
     }
-  else if (event->type == GDK_MOTION_NOTIFY)
+  else if (event->type == GDK_MOTION_NOTIFY ||
+           event->type == GDK_TOUCH_MOTION)
     {
       device = event->motion.device;
       axes = event->motion.axes;
@@ -1235,6 +1244,7 @@ gdk_event_set_device (GdkEvent  *event,
   switch (event->type)
     {
     case GDK_MOTION_NOTIFY:
+    case GDK_TOUCH_MOTION:
       event->motion.device = device;
       break;
     case GDK_BUTTON_PRESS:
@@ -1282,6 +1292,7 @@ gdk_event_get_device (const GdkEvent *event)
   switch (event->type)
     {
     case GDK_MOTION_NOTIFY:
+    case GDK_TOUCH_MOTION:
       return event->motion.device;
     case GDK_BUTTON_PRESS:
     case GDK_2BUTTON_PRESS:
@@ -1301,6 +1312,7 @@ gdk_event_get_device (const GdkEvent *event)
   switch (event->type)
     {
     case GDK_MOTION_NOTIFY:
+    case GDK_TOUCH_MOTION:
     case GDK_BUTTON_PRESS:
     case GDK_2BUTTON_PRESS:
     case GDK_3BUTTON_PRESS:
diff --git a/gdk/gdkevents.h b/gdk/gdkevents.h
index 33cd8b0..1eefdf7 100644
--- a/gdk/gdkevents.h
+++ b/gdk/gdkevents.h
@@ -232,6 +232,7 @@ typedef GdkFilterReturn (*GdkFilterFunc) (GdkXEvent *xevent,
  *   was added in 2.8.
  * @GDK_DAMAGE: the content of the window has been changed. This event type
  *   was added in 2.14.
+ * @GDK_TOUCH_MOTION: A touch device has been updated.
  * @GDK_EVENT_LAST: marks the end of the GdkEventType enumeration. Added in 2.18
  *
  * Specifies the type of the event.
@@ -279,6 +280,7 @@ typedef enum
   GDK_OWNER_CHANGE      = 34,
   GDK_GRAB_BROKEN       = 35,
   GDK_DAMAGE            = 36,
+  GDK_TOUCH_MOTION      = 37,
   GDK_EVENT_LAST        /* helper variable for decls */
 } GdkEventType;
 
@@ -533,8 +535,9 @@ struct _GdkEventVisibility
  *   screen.
  * @y_root: the y coordinate of the pointer relative to the root of the
  *   screen.
+ * @touch_id: touch ID, only meaningful if event is of type %GDK_TOUCH_MOTION.
  *
- * Generated when the pointer moves.
+ * Generated when the pointer/touch moves.
  */
 struct _GdkEventMotion
 {
@@ -549,6 +552,7 @@ struct _GdkEventMotion
   gint16 is_hint;
   GdkDevice *device;
   gdouble x_root, y_root;
+  guint touch_id;
 };
 
 /**
diff --git a/gdk/gdktypes.h b/gdk/gdktypes.h
index 577ab96..d8712b6 100644
--- a/gdk/gdktypes.h
+++ b/gdk/gdktypes.h
@@ -350,6 +350,7 @@ typedef enum
  * @GDK_SUBSTRUCTURE_MASK: receive events about window configuration changes of
  *   child windows
  * @GDK_SCROLL_MASK: receive scroll events
+ * @GDK_TOUCH_MASK: receive (multi)touch events
  * @GDK_ALL_EVENTS_MASK: the combination of all the above event masks.
  *
  * A set of bit-flags to indicate which events a window is to receive.
@@ -389,7 +390,8 @@ typedef enum
   GDK_PROXIMITY_OUT_MASK        = 1 << 19,
   GDK_SUBSTRUCTURE_MASK         = 1 << 20,
   GDK_SCROLL_MASK               = 1 << 21,
-  GDK_ALL_EVENTS_MASK           = 0x3FFFFE
+  GDK_TOUCH_MASK                = 1 << 22,
+  GDK_ALL_EVENTS_MASK           = 0x3FFFFF
 } GdkEventMask;
 
 /**



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