[gtk+/xi2: 1139/1239] GdkWindow: Find native window correctly in gdk_window_set_device_events().



commit d605521b2e829afc40726c3f28e19d276c6a2bb1
Author: Carlos Garnacho <carlos gnome org>
Date:   Tue Sep 15 09:49:38 2009 +0200

    GdkWindow: Find native window correctly in gdk_window_set_device_events().
    
    Also, initialize the device_events hashtable.

 gdk/gdkwindow.c |   25 +++++++++++++++++++++----
 1 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 0397665..1124ce0 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -6602,8 +6602,10 @@ gdk_window_set_device_events (GdkWindow    *window,
                               GdkDevice    *device,
                               GdkEventMask  event_mask)
 {
+  GdkEventMask device_mask;
   GdkWindowObject *private;
   GdkDisplay *display;
+  GdkWindow *native;
 
   g_return_if_fail (GDK_IS_WINDOW (window));
   g_return_if_fail (GDK_IS_DEVICE (device));
@@ -6619,6 +6621,9 @@ gdk_window_set_device_events (GdkWindow    *window,
       !(event_mask & GDK_POINTER_MOTION_HINT_MASK))
     _gdk_display_enable_motion_hints (display);
 
+  if (G_UNLIKELY (!private->device_events))
+    private->device_events = g_hash_table_new (NULL, NULL);
+
   if (event_mask == 0)
     {
       /* FIXME: unsetting events on a master device
@@ -6630,13 +6635,25 @@ gdk_window_set_device_events (GdkWindow    *window,
     g_hash_table_insert (private->device_events, device,
                          GINT_TO_POINTER (event_mask));
 
-  if (gdk_window_has_impl (private))
+  if (_gdk_native_windows)
+    native = window;
+  else
+    native = gdk_window_get_toplevel (window);
+
+  while (gdk_window_is_offscreen ((GdkWindowObject *)native))
     {
-      GdkEventMask device_mask;
+      native = gdk_offscreen_window_get_embedder (native);
+
+      if (native == NULL ||
+	  (!_gdk_window_has_impl (native) &&
+	   !gdk_window_is_viewable (native)))
+	return;
 
-      device_mask = get_native_device_event_mask (private, device);
-      GDK_DEVICE_GET_CLASS (device)->select_window_events (device, window, device_mask);
+      native = gdk_window_get_toplevel (native);
     }
+
+  device_mask = get_native_device_event_mask (private, device);
+  GDK_DEVICE_GET_CLASS (device)->select_window_events (device, window, device_mask);
 }
 
 GdkEventMask



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