[gtk+/client-side-windows: 8/284] For foreign parents, use the real parent not the root (which is what we list as parent in the APIs)



commit ec4f8baa08f38aed8e00d5cc39007ad39a607093
Author: Alexander Larsson <alexl redhat com>
Date:   Wed Dec 3 22:00:56 2008 +0100

    For foreign parents, use the real parent not the root (which is what we list as parent in the APIs)
---
 gdk/gdkinternals.h      |    1 +
 gdk/gdkwindow.c         |   15 +++++++++++----
 gdk/x11/gdkwindow-x11.c |    3 ++-
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index b8fd252..3a1c1c6 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -267,6 +267,7 @@ GdkPixmap *_gdk_bitmap_create_from_data  (GdkDrawable    *drawable,
                                           gint            height);
 
 void       _gdk_window_impl_new          (GdkWindow      *window,
+					  GdkWindow      *real_parent,
 					  GdkScreen      *screen,
 					  GdkVisual      *visual,
 					  GdkEventMask    event_mask,
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index fabe972..0beba73 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -636,6 +636,7 @@ gdk_window_new (GdkWindow     *parent,
   int x, y, depth;
   gboolean native;
   GdkEventMask event_mask;
+  GdkWindow *real_parent;
   
   g_return_val_if_fail (attributes != NULL, NULL);
   
@@ -661,6 +662,7 @@ gdk_window_new (GdkWindow     *parent,
   /* Windows with a foreign parent are treated as if they are children
    * of the root window, except for actual creation.
    */
+  real_parent = parent;
   if (GDK_WINDOW_TYPE (parent) == GDK_WINDOW_FOREIGN)
     parent = gdk_screen_get_root_window (screen);
 
@@ -783,7 +785,7 @@ gdk_window_new (GdkWindow     *parent,
 	event_mask = GDK_EXPOSURE_MASK;
       
       /* Create the impl */
-      _gdk_window_impl_new (window, screen, visual, event_mask, attributes, attributes_mask);
+      _gdk_window_impl_new (window, real_parent, screen, visual, event_mask, attributes, attributes_mask);
     }
   else
     {
@@ -1019,9 +1021,9 @@ gdk_window_set_has_native (GdkWindow *window, gboolean has_native)
   GdkVisual *visual;
 
   g_return_if_fail (GDK_IS_WINDOW (window));
-  g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_ROOT);
 
-  if (GDK_WINDOW_DESTROYED (window))
+  if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_ROOT ||
+      GDK_WINDOW_DESTROYED (window))
     return;
 
   private = (GdkWindowObject *) window;
@@ -1043,7 +1045,7 @@ gdk_window_set_has_native (GdkWindow *window, gboolean has_native)
       visual = gdk_drawable_get_visual (window);
 
       old_impl = private->impl;
-      _gdk_window_impl_new (window, screen, visual, GDK_EXPOSURE_MASK, NULL, 0);
+      _gdk_window_impl_new (window, private->parent, screen, visual, GDK_EXPOSURE_MASK, NULL, 0);
       new_impl = private->impl;
       
       private->impl = old_impl;
@@ -1482,6 +1484,11 @@ gdk_window_add_filter (GdkWindow     *window,
   private = (GdkWindowObject*) window;
   if (private && GDK_WINDOW_DESTROYED (window))
     return;
+
+  /* Filters are for the native events on the native window, so
+     ensure there is a native window. */
+  if (window)
+    gdk_window_set_has_native (window, TRUE);
   
   if (private)
     tmp_list = private->filters;
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index b5a3a3a..ed9a854 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -624,6 +624,7 @@ setup_toplevel_window (GdkWindow *window,
 
 void
 _gdk_window_impl_new (GdkWindow     *window,
+		      GdkWindow     *real_parent,
 		      GdkScreen     *screen,
 		      GdkVisual     *visual,
 		      GdkEventMask   event_mask,
@@ -652,7 +653,7 @@ _gdk_window_impl_new (GdkWindow     *window,
   private = (GdkWindowObject *) window;
   
   screen_x11 = GDK_SCREEN_X11 (screen);
-  xparent = GDK_WINDOW_XID (private->parent);
+  xparent = GDK_WINDOW_XID (real_parent);
   
   impl = g_object_new (_gdk_window_impl_get_type (), NULL);
   private->impl = (GdkDrawable *)impl;



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