[gtk+/multitouch-for-3.4: 29/89] gdk: Keep track of the last slave device used



commit cbc677986eea831bc411250f0c4c91e940b838d7
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Dec 3 15:04:19 2011 +0100

    gdk: Keep track of the last slave device used
    
    This last slave device (stored per master) is used to fill
    in the missing slave device in synthesized crossing events
    not directly caused by a device event (ie. due to configure
    events or grabs)

 gdk/gdkdisplayprivate.h  |    1 +
 gdk/gdkwindow.c          |   15 ++++++++++++---
 gdk/x11/gdkdisplay-x11.c |    5 ++++-
 3 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/gdk/gdkdisplayprivate.h b/gdk/gdkdisplayprivate.h
index 2c7b511..8084332 100644
--- a/gdk/gdkdisplayprivate.h
+++ b/gdk/gdkdisplayprivate.h
@@ -75,6 +75,7 @@ typedef struct
   gdouble toplevel_x, toplevel_y;
   guint32 state;
   guint32 button;
+  GdkDevice *last_slave;
 } GdkPointerWindowInfo;
 
 typedef struct
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index bcbd335..ed39799 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -9045,7 +9045,7 @@ do_synthesize_crossing_event (gpointer data)
               _gdk_synthesize_crossing_events (display,
                                                pointer_info->window_under_pointer,
                                                new_window_under_pointer,
-                                               device, NULL,
+                                               device, pointer_info->last_slave,
                                                GDK_CROSSING_NORMAL,
                                                pointer_info->toplevel_x,
                                                pointer_info->toplevel_y,
@@ -9571,6 +9571,17 @@ _gdk_windowing_got_event (GdkDisplay *display,
     {
       GdkInputMode mode;
 
+      pointer_info = _gdk_display_get_pointer_info (display, device);
+
+      if (pointer_info)
+        {
+          if (source_device != pointer_info->last_slave &&
+              gdk_device_get_device_type (source_device) == GDK_DEVICE_TYPE_SLAVE)
+            pointer_info->last_slave = source_device;
+          else
+            source_device = pointer_info->last_slave;
+        }
+
       g_object_get (device, "input-mode", &mode, NULL);
       _gdk_display_device_grab_update (display, device, source_device, serial);
 
@@ -9589,8 +9600,6 @@ _gdk_windowing_got_event (GdkDisplay *display,
   if (!event_window)
     return;
 
-  pointer_info = _gdk_display_get_pointer_info (display, device);
-
 #ifdef DEBUG_WINDOW_PRINTING
   if (event->type == GDK_KEY_PRESS &&
       (event->key.keyval == 0xa7 ||
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index 897d713..ae6896c 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -1579,9 +1579,12 @@ device_grab_update_callback (GdkDisplay *display,
                              gpointer    data,
                              gulong      serial)
 {
+  GdkPointerWindowInfo *pointer_info;
   GdkDevice *device = data;
 
-  _gdk_display_device_grab_update (display, device, NULL, serial);
+  pointer_info = _gdk_display_get_pointer_info (display, device);
+  _gdk_display_device_grab_update (display, device,
+                                   pointer_info->last_slave, serial);
 }
 
 #define XSERVER_TIME_IS_LATER(time1, time2)                        \



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