summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2004-10-05 05:40:42 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2004-10-05 05:40:42 +0000
commit221db8e02516702b14e12e19f3256b2d49a4f256 (patch)
treec89ed61da48af95247a6c7fa8ca60020efbd5136 /gdk
parentfd322012100dc5a35668946395d6eb32c8895a8e (diff)
downloadgdk-pixbuf-221db8e02516702b14e12e19f3256b2d49a4f256.tar.gz
Return a new reference to an existing GdkWindow if one already exists.
2004-10-05 Matthias Clasen <mclasen@redhat.com> * gdk/x11/gdkwindow-x11.c (gdk_window_foreign_new_for_display): Return a new reference to an existing GdkWindow if one already exists. (#151378, Gustavo Carneiro)
Diffstat (limited to 'gdk')
-rw-r--r--gdk/x11/gdkwindow-x11.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index 6a281d88e..123073917 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -947,13 +947,16 @@ x_event_mask_to_gdk_event_mask (long mask)
* @anid: a native window handle.
*
* Wraps a native window in a #GdkWindow.
- * This may fail if the window has been destroyed.
+ * This may fail if the window has been destroyed. If the window
+ * was already known to GDK, a new reference to the existing
+ * #GdkWindow is returned.
*
* For example in the X backend, a native window handle is an Xlib
* <type>XID</type>.
*
- * Return value: the newly-created #GdkWindow wrapper for the
- * native window or %NULL if the window has been destroyed.
+ * Return value: a #GdkWindow wrapper for the native window or
+ * %NULL if the window has been destroyed. The wrapper will be
+ * newly created, if one doesn't exist already.
*
* Since: 2.2
**/
@@ -975,7 +978,10 @@ gdk_window_foreign_new_for_display (GdkDisplay *display,
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
display_x11 = GDK_DISPLAY_X11 (display);
-
+
+ if ((window = gdk_xid_table_lookup_for_display (display, anid)) != NULL)
+ return g_object_ref (window);
+
gdk_error_trap_push ();
result = XGetWindowAttributes (display_x11->xdisplay, anid, &attrs);
if (gdk_error_trap_pop () || !result)