[gtk+/xi2: 528/1239] Implement gdk_event_get_device().



commit d1667984d09e664f346750fb3a5664f6bd8075f4
Author: Carlos Garnacho <carlos lanedo com>
Date:   Sat Jul 11 22:07:49 2009 +0200

    Implement gdk_event_get_device().

 gdk/gdkevents.c |   22 ++++++++++++++++++++++
 gdk/gdkevents.h |    1 +
 2 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index 5d35a7d..b7fc9f2 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -918,6 +918,28 @@ gdk_event_get_axis (const GdkEvent *event,
   return gdk_device_get_axis (device, axes, axis_use, value);
 }
 
+GdkDevice *
+gdk_event_get_device (const GdkEvent *event)
+{
+  switch (event->type)
+    {
+    case GDK_MOTION_NOTIFY:
+      return ((GdkEventMotion *) event)->device;
+    case GDK_BUTTON_PRESS:
+    case GDK_2BUTTON_PRESS:
+    case GDK_3BUTTON_PRESS:
+    case GDK_BUTTON_RELEASE:
+      return ((GdkEventButton *) event)->device;
+    case GDK_ENTER_NOTIFY:
+    case GDK_LEAVE_NOTIFY:
+      return ((GdkEventCrossing *) event)->device;
+    case GDK_SCROLL:
+      return ((GdkEventScroll *) event)->device;
+    default:
+      return NULL;
+    }
+}
+
 /**
  * gdk_event_request_motions:
  * @event: a valid #GdkEvent
diff --git a/gdk/gdkevents.h b/gdk/gdkevents.h
index eb42c49..8eaf71c 100644
--- a/gdk/gdkevents.h
+++ b/gdk/gdkevents.h
@@ -539,6 +539,7 @@ gboolean  gdk_event_get_root_coords	(const GdkEvent  *event,
 gboolean  gdk_event_get_axis            (const GdkEvent  *event,
                                          GdkAxisUse       axis_use,
                                          gdouble         *value);
+GdkDevice* gdk_event_get_device         (const GdkEvent  *event);
 void      gdk_event_request_motions     (const GdkEventMotion *event);
 
 gboolean  gdk_events_get_distance       (GdkEvent        *event1,



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