[gtk+/touchscreens: 44/49] gdk: Keep track of the last slave device used



commit 49916b3081c73a28425d5f84a45263ebd428e103
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 cc251a9..874c9d3 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -8982,7 +8982,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,
@@ -9508,6 +9508,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);
 
@@ -9526,8 +9537,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 ecf9f09..1b69552 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]