[gtk+] wayland: Store the device that does a grab for a window on the window



commit bdca0520e696a5671f5c02088e92366891c135e8
Author: Rob Bradford <rob linux intel com>
Date:   Mon Feb 27 14:06:22 2012 +0000

    wayland: Store the device that does a grab for a window on the window
    
    This allows us to get the device if we need to make the window a popup. This
    relies on the side effect that GTK calls into GDK to take a grab before the
    popup window is shown.

 gdk/wayland/gdkdevice-wayland.c  |   14 ++++++++++++++
 gdk/wayland/gdkprivate-wayland.h |    4 ++++
 gdk/wayland/gdkwindow-wayland.c  |   15 +++++++++++++++
 3 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 7381d21..9e8e6b1 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -243,6 +243,15 @@ gdk_device_core_grab (GdkDevice    *device,
 
       wayland_device->pointer_grab_window = window;
       wayland_device->pointer_grab_time = time_;
+
+      /* FIXME: This probably breaks if you end up with multiple grabs on the
+       * same window - but we need to know the input device for when we are
+       * asked to map a popup window so that the grab can be managed by the
+       * compositor.
+       */
+      _gdk_wayland_window_set_device_grabbed (window,
+                                              wayland_device->device,
+                                              time_);
     }
 
   return GDK_GRAB_SUCCESS;
@@ -252,6 +261,7 @@ static void
 gdk_device_core_ungrab (GdkDevice *device,
                         guint32    time_)
 {
+  GdkWaylandDevice *wayland_device = GDK_DEVICE_CORE (device)->device;
   GdkDisplay *display;
   GdkDeviceGrabInfo *grab;
 
@@ -268,6 +278,10 @@ gdk_device_core_ungrab (GdkDevice *device,
 
       if (grab)
         grab->serial_end = grab->serial_start;
+
+      _gdk_wayland_window_set_device_grabbed (wayland_device->pointer_grab_window,
+                                              NULL,
+                                              0);
     }
 }
 
diff --git a/gdk/wayland/gdkprivate-wayland.h b/gdk/wayland/gdkprivate-wayland.h
index de8d5cc..6281591 100644
--- a/gdk/wayland/gdkprivate-wayland.h
+++ b/gdk/wayland/gdkprivate-wayland.h
@@ -146,4 +146,8 @@ void _gdk_wayland_display_manager_add_display (GdkDisplayManager *manager,
 void _gdk_wayland_display_manager_remove_display (GdkDisplayManager *manager,
 						  GdkDisplay        *display);
 
+void _gdk_wayland_window_set_device_grabbed (GdkWindow *window,
+                                             struct wl_input_device *input_device,
+                                             guint32 time_);
+
 #endif /* __GDK_PRIVATE_WAYLAND_H__ */
diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c
index d76347b..cdadd47 100644
--- a/gdk/wayland/gdkwindow-wayland.c
+++ b/gdk/wayland/gdkwindow-wayland.c
@@ -119,6 +119,9 @@ struct _GdkWindowImplWayland
 
   GdkGeometry geometry_hints;
   GdkWindowHints geometry_mask;
+
+  struct wl_input_device *grab_input_device;
+  guint32 grab_time;
 };
 
 struct _GdkWindowImplWaylandClass
@@ -1477,3 +1480,15 @@ _gdk_window_impl_wayland_class_init (GdkWindowImplWaylandClass *klass)
   impl_class->change_property = gdk_wayland_window_change_property;
   impl_class->delete_property = gdk_wayland_window_delete_property;
 }
+
+
+void
+_gdk_wayland_window_set_device_grabbed (GdkWindow              *window,
+                                        struct wl_input_device *input_device,
+                                        guint32                 time_)
+{
+  GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+
+  impl->grab_input_device = input_device;
+  impl->grab_time = time_;
+}



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