[gimp/gtk3-port: 221/237] app: when checking for a device change, check the event's source device



commit 8624215b641037dd740a63b647cce0c5213f198b
Author: Michael Natterer <mitch gimp org>
Date:   Sun Feb 6 13:34:53 2011 +0100

    app: when checking for a device change, check the event's source device
    
    because the events we receive always come from either master or
    floating devices, but never from a slave source device.

 app/widgets/gimpdevices.c |   42 +++++++++++++++---------------------------
 1 files changed, 15 insertions(+), 27 deletions(-)
---
diff --git a/app/widgets/gimpdevices.c b/app/widgets/gimpdevices.c
index 526f443..c0fff83 100644
--- a/app/widgets/gimpdevices.c
+++ b/app/widgets/gimpdevices.c
@@ -354,36 +354,24 @@ gimp_devices_check_change (Gimp     *gimp,
 
   g_return_val_if_fail (manager != NULL, FALSE);
 
-  switch (event->type)
-    {
-    case GDK_MOTION_NOTIFY:
-      device = ((GdkEventMotion *) event)->device;
-      break;
-
-    case GDK_BUTTON_PRESS:
-    case GDK_2BUTTON_PRESS:
-    case GDK_3BUTTON_PRESS:
-    case GDK_BUTTON_RELEASE:
-      device = ((GdkEventButton *) event)->device;
-      break;
-
-    case GDK_PROXIMITY_IN:
-    case GDK_PROXIMITY_OUT:
-      device = ((GdkEventProximity *) event)->device;
-      break;
-
-    case GDK_SCROLL:
-      device = ((GdkEventScroll *) event)->device;
-      break;
-
-    default:
-      device = manager->current_device->device;
-      break;
-    }
+  device = gdk_event_get_source_device (event);
+
+  if (! device)
+    device = manager->current_device->device;
 
   device_info = gimp_device_info_get_by_device (device);
 
-  if (device_info != manager->current_device)
+  if (! device_info)
+    {
+      device = gdk_event_get_device (event);
+
+      if (! device)
+        device = manager->current_device->device;
+
+      device_info = gimp_device_info_get_by_device (device);
+    }
+
+  if (device_info && device_info != manager->current_device)
     {
       gimp_devices_select_device (manager, device_info);
       return TRUE;



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