[gtk+/xi21: 2/12] Add touch motion event type and mask.



commit 02f62468aa5c36fb463725cca0771754f8fe4075
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 25853da..c15cd10 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));
@@ -647,6 +649,7 @@ gdk_event_free (GdkEvent *event)
       break;
       
     case GDK_MOTION_NOTIFY:
+    case GDK_TOUCH_MOTION:
       g_free (event->motion.axes);
       break;
       
@@ -692,6 +695,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:
@@ -767,6 +771,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:
@@ -865,6 +870,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;
@@ -904,6 +910,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;
@@ -972,7 +979,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;
@@ -1008,7 +1016,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;
@@ -1045,6 +1054,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:
@@ -1092,6 +1102,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:
@@ -1111,6 +1122,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 f1684ba..dee6df3 100644
--- a/gdk/gdkevents.h
+++ b/gdk/gdkevents.h
@@ -213,6 +213,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.
@@ -260,6 +261,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;
 
@@ -500,8 +502,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
 {
@@ -516,6 +519,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 c3ab38f..8d51d83 100644
--- a/gdk/gdktypes.h
+++ b/gdk/gdktypes.h
@@ -288,6 +288,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.
@@ -327,7 +328,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]