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



commit 708fe8aece6de87b48bb9cba2ef59f3951125577
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 153fb83..741f582 100644
--- a/app/widgets/gimpdevices.c
+++ b/app/widgets/gimpdevices.c
@@ -273,36 +273,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]