[gtk+/multitouch: 51/121] gdk: Ensure that GdkPointerWindowInfo is only generated for pointers



commit 720f7c385e8936cf7ad70b72cb42753f6e90ac77
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Dec 6 20:29:22 2011 +0100

    gdk: Ensure that GdkPointerWindowInfo is only generated for pointers

 gdk/gdkdisplay.c |    3 +++
 gdk/gdkwindow.c  |   26 +++++++++++++++-----------
 2 files changed, 18 insertions(+), 11 deletions(-)
---
diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c
index 48a556c..f2a40ce 100644
--- a/gdk/gdkdisplay.c
+++ b/gdk/gdkdisplay.c
@@ -1130,6 +1130,9 @@ _gdk_display_get_pointer_info (GdkDisplay *display,
 {
   GdkPointerWindowInfo *info;
 
+  if (device && gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
+    device = gdk_device_get_associated_device (device);
+
   if (G_UNLIKELY (!device))
     return NULL;
 
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 2aabcfd..1862abe 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -9654,10 +9654,10 @@ _gdk_windowing_got_event (GdkDisplay *display,
     {
       GdkInputMode mode;
 
-      pointer_info = _gdk_display_get_pointer_info (display, device);
-
-      if (pointer_info)
+      if (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD)
         {
+          pointer_info = _gdk_display_get_pointer_info (display, device);
+
           if (source_device != pointer_info->last_slave &&
               gdk_device_get_device_type (source_device) == GDK_DEVICE_TYPE_SLAVE)
             pointer_info->last_slave = source_device;
@@ -9767,15 +9767,19 @@ _gdk_windowing_got_event (GdkDisplay *display,
 	}
     }
 
-  /* Store last pointer window and position/state */
-  old_state = pointer_info->state;
-  old_button = pointer_info->button;
+  if (pointer_info)
+    {
+      /* Store last pointer window and position/state */
+      old_state = pointer_info->state;
+      old_button = pointer_info->button;
+
+      gdk_event_get_coords (event, &x, &y);
+      convert_native_coords_to_toplevel (event_window, x, y,  &x, &y);
+      pointer_info->toplevel_x = x;
+      pointer_info->toplevel_y = y;
+      gdk_event_get_state (event, &pointer_info->state);
+    }
 
-  gdk_event_get_coords (event, &x, &y);
-  convert_native_coords_to_toplevel (event_window, x, y,  &x, &y);
-  pointer_info->toplevel_x = x;
-  pointer_info->toplevel_y = y;
-  gdk_event_get_state (event, &pointer_info->state);
   if (event->type == GDK_BUTTON_PRESS ||
       event->type == GDK_BUTTON_RELEASE)
     pointer_info->button = event->button.button;



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