[gtk+/multitouch: 7/40] Add gdk_event_get_touch_id()



commit da079212b733cddb439afbb8e702b4a6bbb63c30
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Mar 1 08:36:54 2011 +0100

    Add gdk_event_get_touch_id()
    
    Just a helper function to get the touch ID from touch events, it
    returns FALSE in any other case.

 docs/reference/gdk/gdk3-sections.txt |    2 +
 gdk/gdk.symbols                      |    1 +
 gdk/gdkevents.c                      |   39 ++++++++++++++++++++++++++++++++++
 gdk/gdkevents.h                      |    3 ++
 4 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt
index d5deb42..5f6ba56 100644
--- a/docs/reference/gdk/gdk3-sections.txt
+++ b/docs/reference/gdk/gdk3-sections.txt
@@ -778,11 +778,13 @@ gdk_event_get_root_coords
 gdk_event_get_scroll_direction
 gdk_event_get_state
 gdk_event_get_time
+gdk_event_get_touch_id
 gdk_event_request_motions
 gdk_events_get_angle
 gdk_events_get_center
 gdk_events_get_distance
 gdk_event_triggers_context_menu
+gdk_event_get_touch_id
 
 <SUBSECTION>
 gdk_event_handler_set
diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols
index 21f1667..5f37e05 100644
--- a/gdk/gdk.symbols
+++ b/gdk/gdk.symbols
@@ -168,6 +168,7 @@ gdk_event_get_scroll_direction
 gdk_event_get_source_device
 gdk_event_get_state
 gdk_event_get_time
+gdk_event_get_touch_id
 gdk_event_get_type
 gdk_event_handler_set
 gdk_event_mask_get_type
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index 92ff6f9..dd21942 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -1723,6 +1723,45 @@ gdk_event_get_screen (const GdkEvent *event)
 }
 
 /**
+ * gdk_event_get_touch_id:
+ * @event: a #GdkEvent
+ * @touch_id: return location of the touch ID of a touch event
+ *
+ * If @event if of type %GDK_TOUCH_MOTION, %GDK_TOUCH_PRESS or
+ * %GDK_TOUCH_RELEASE, fills in @touch_id and returns %TRUE,
+ * else it returns %FALSE.
+ *
+ * Returns: %TRUE if the touch ID can be extracted from @event.
+ **/
+gboolean
+gdk_event_get_touch_id (const GdkEvent *event,
+                        guint          *touch_id)
+{
+  if (!event)
+    return FALSE;
+
+  if (event->type == GDK_TOUCH_MOTION)
+    {
+      if (touch_id)
+        *touch_id = event->motion.touch_id;
+      return TRUE;
+    }
+  else if (event->type == GDK_TOUCH_PRESS ||
+           event->type == GDK_TOUCH_RELEASE)
+    {
+      if (touch_id)
+        *touch_id = event->button.touch_id;
+      return TRUE;
+    }
+  else
+    {
+      if (touch_id)
+        *touch_id = 0;
+      return FALSE;
+    }
+}
+
+/**
  * gdk_set_show_events:
  * @show_events:  %TRUE to output event debugging information.
  * 
diff --git a/gdk/gdkevents.h b/gdk/gdkevents.h
index 8eed43b..e5b566e 100644
--- a/gdk/gdkevents.h
+++ b/gdk/gdkevents.h
@@ -1142,6 +1142,9 @@ void       gdk_event_set_screen         (GdkEvent        *event,
                                          GdkScreen       *screen);
 GdkScreen *gdk_event_get_screen         (const GdkEvent  *event);
 
+gboolean   gdk_event_get_touch_id       (const GdkEvent  *event,
+                                         guint           *touch_id);
+
 void	  gdk_set_show_events		(gboolean	 show_events);
 gboolean  gdk_get_show_events		(void);
 



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