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



commit 2e5b8438985d2ea53e5729b67a683e32854ba786
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 1b5d281..1799cc5 100644
--- a/app/widgets/gimpdevices.c
+++ b/app/widgets/gimpdevices.c
@@ -272,36 +272,24 @@ gimp_devices_check_change (Gimp     *gimp,
 
   g_return_val_if_fail (GIMP_IS_DEVICE_MANAGER (manager), 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 = gimp_device_manager_get_current_device (manager)->device;
-      break;
-    }
+  device = gdk_event_get_source_device (event);
+
+  if (! device)
+    device = gimp_device_manager_get_current_device (manager)->device;
 
   device_info = gimp_device_info_get_by_device (device);
 
-  if (device_info != gimp_device_manager_get_current_device (manager))
+  if (! device_info)
+    {
+      device = gdk_event_get_device (event);
+
+      if (! device)
+        device = gimp_device_manager_get_current_device (manager)->device;
+
+      device_info = gimp_device_info_get_by_device (device);
+    }
+
+  if (device_info && device_info != gimp_device_manager_get_current_device (manager))
     {
       gimp_device_manager_set_current_device (manager, device_info);
       return TRUE;



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