[gtk+/gdk-backend: 50/91] Make gdk_window_{lookup, foreign_new}_for_display backend specific



commit e7147fd909e675576fa4d262c13a9be9170b3719
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Dec 15 01:39:30 2010 -0500

    Make gdk_window_{lookup,foreign_new}_for_display backend specific
    
    At the same time, make GDK_IS_DISPLAY_X11 available in gdkx.h, and
    add some exemplaric ifdefs to GTK+ code.

 docs/reference/gdk/gdk3-sections.txt |    6 +-
 docs/tools/shooter.c                 |    2 +-
 gdk/gdk.symbols                      |    6 +-
 gdk/gdkwindow.c                      |   37 --------
 gdk/gdkwindow.h                      |   13 +---
 gdk/x11/gdkdevice-core.c             |    8 +-
 gdk/x11/gdkdevice-xi2.c              |    8 +-
 gdk/x11/gdkdevicemanager-core.c      |    6 +-
 gdk/x11/gdkdevicemanager-xi.c        |    4 +-
 gdk/x11/gdkdevicemanager-xi2.c       |    6 +-
 gdk/x11/gdkdisplay-x11.c             |    2 +-
 gdk/x11/gdkdisplay-x11.h             |    1 -
 gdk/x11/gdkdnd-x11.c                 |   18 ++--
 gdk/x11/gdkeventsource.c             |    2 +-
 gdk/x11/gdkscreen-x11.c              |   12 ++--
 gdk/x11/gdkselection-x11.c           |    2 +-
 gdk/x11/gdkwindow-x11.c              |  152 ++++++++++++++++------------------
 gdk/x11/gdkx.h                       |    6 ++
 gtk/gtkplug-x11.c                    |    4 +-
 gtk/gtkplug.c                        |   17 ++++-
 gtk/gtkselection.c                   |   20 ++--
 gtk/gtksocket.c                      |   38 ++++++---
 gtk/gtktrayicon-x11.c                |   14 ++--
 23 files changed, 178 insertions(+), 206 deletions(-)
---
diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt
index 1a1db3b..02a3608 100644
--- a/docs/reference/gdk/gdk3-sections.txt
+++ b/docs/reference/gdk/gdk3-sections.txt
@@ -954,12 +954,10 @@ GDK_SCREEN_XSCREEN
 GDK_CURSOR_XCURSOR
 GDK_CURSOR_XDISPLAY
 gdkx_visual_get
-gdk_window_foreign_new
-gdk_window_foreign_new_for_display
+gdk_x11_window_foreign_new_for_display
 gdk_xid_table_lookup
 gdk_xid_table_lookup_for_display
-gdk_window_lookup
-gdk_window_lookup_for_display
+gdk_x11_window_lookup_for_display
 gdk_x11_lookup_xdisplay
 gdk_x11_get_server_time
 gdk_net_wm_supports
diff --git a/docs/tools/shooter.c b/docs/tools/shooter.c
index f9492f6..fa7e845 100644
--- a/docs/tools/shooter.c
+++ b/docs/tools/shooter.c
@@ -138,7 +138,7 @@ take_window_shot (Window   child,
   else
     xid = child;
 
-  window = gdk_window_foreign_new (xid);
+  window = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (), xid);
 
   width = gdk_window_get_width (window);
   height = gdk_window_get_height (window);
diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols
index 8a74819..dc01651 100644
--- a/gdk/gdk.symbols
+++ b/gdk/gdk.symbols
@@ -399,8 +399,6 @@ gdk_window_end_paint
 gdk_window_ensure_native
 gdk_window_flush
 gdk_window_focus
-gdk_window_foreign_new
-gdk_window_foreign_new_for_display
 gdk_window_freeze_toplevel_updates_libgtk_only
 gdk_window_freeze_updates
 gdk_window_fullscreen
@@ -459,8 +457,6 @@ gdk_window_is_input_only
 gdk_window_is_shaped
 gdk_window_is_viewable
 gdk_window_is_visible
-gdk_window_lookup
-gdk_window_lookup_for_display
 gdk_window_lower
 gdk_window_maximize
 gdk_window_merge_child_input_shapes
@@ -565,6 +561,8 @@ gdk_x11_screen_supports_net_wm_hint
 gdk_x11_set_sm_client_id
 gdk_x11_ungrab_server
 gdk_x11_visual_get_xvisual
+gdk_x11_window_foreign_new_for_display
+gdk_x11_window_lookup_for_display
 gdk_x11_window_get_xid
 gdk_x11_window_move_to_current_desktop
 gdk_x11_window_set_user_time
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 503831e..535ec22 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -5028,25 +5028,6 @@ gdk_get_default_root_window (void)
   return gdk_screen_get_root_window (gdk_screen_get_default ());
 }
 
-/**
- * gdk_window_foreign_new:
- * @anid: a native window handle.
- *
- * Wraps a native window for the default display in a #GdkWindow.
- * This may fail if the window has been destroyed.
- *
- * For example in the X backend, a native window handle is an Xlib
- * <type>XID</type>.
- *
- * Return value: (transfer full): the newly-created #GdkWindow wrapper
- *    for the native window, or %NULL if the window has been destroyed.
- **/
-GdkWindow *
-gdk_window_foreign_new (GdkNativeWindow anid)
-{
-  return gdk_window_foreign_new_for_display (gdk_display_get_default (), anid);
-}
-
 static void
 get_all_native_children (GdkWindow *window,
 			 GList **native)
@@ -10711,21 +10692,3 @@ gdk_drag_begin_for_device (GdkWindow     *window,
 {
   return GDK_WINDOW_IMPL_GET_CLASS (window->impl)->drag_begin (window, device, targets);
 }
-
-/**
- * gdk_window_lookup:
- * @anid: a native window handle
- *
- * Looks up the #GdkWindow that wraps the given native window handle.
- *
- * For example in the X backend, a native window handle is an Xlib
- * <type>XID</type>.
- *
- * Return value: (transfer none): the #GdkWindow wrapper for the native
- *    window, or %NULL if there is none.
- **/
-GdkWindow *
-gdk_window_lookup (GdkNativeWindow anid)
-{
-  return gdk_window_lookup_for_display (gdk_display_get_default (), anid);
-}
diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h
index f7ac2a5..582a9bf 100644
--- a/gdk/gdkwindow.h
+++ b/gdk/gdkwindow.h
@@ -642,18 +642,7 @@ GdkWindowState gdk_window_get_state (GdkWindow *window);
  * window gravity on all children.
  */
 gboolean gdk_window_set_static_gravities (GdkWindow *window,
-					  gboolean   use_static);   
-
-/* Functions to create/lookup windows from their native equivalents */ 
-#ifndef GDK_MULTIHEAD_SAFE
-GdkWindow*    gdk_window_foreign_new (GdkNativeWindow anid);
-GdkWindow*    gdk_window_lookup      (GdkNativeWindow anid);
-#endif
-GdkWindow    *gdk_window_foreign_new_for_display (GdkDisplay      *display,
-						  GdkNativeWindow  anid);
-GdkWindow*    gdk_window_lookup_for_display (GdkDisplay      *display,
-					     GdkNativeWindow  anid);
-
+                                          gboolean   use_static);
 
 /* GdkWindow */
 
diff --git a/gdk/x11/gdkdevice-core.c b/gdk/x11/gdkdevice-core.c
index ff0d456..7e4613b 100644
--- a/gdk/x11/gdkdevice-core.c
+++ b/gdk/x11/gdkdevice-core.c
@@ -289,10 +289,10 @@ gdk_device_core_query_state (GdkDevice        *device,
     }
 
   if (root_window)
-    *root_window = gdk_window_lookup_for_display (display, xroot_window);
+    *root_window = gdk_x11_window_lookup_for_display (display, xroot_window);
 
   if (child_window)
-    *child_window = gdk_window_lookup_for_display (display, xchild_window);
+    *child_window = gdk_x11_window_lookup_for_display (display, xchild_window);
 
   if (root_x)
     *root_x = xroot_x;
@@ -529,7 +529,7 @@ gdk_device_core_window_at_position (GdkDevice       *device,
         break;
 
       if (get_toplevel && last != root &&
-          (window = gdk_window_lookup_for_display (display, last)) != NULL &&
+          (window = gdk_x11_window_lookup_for_display (display, last)) != NULL &&
           window->window_type != GDK_WINDOW_FOREIGN)
         {
           xwindow = last;
@@ -539,7 +539,7 @@ gdk_device_core_window_at_position (GdkDevice       *device,
 
   gdk_x11_display_ungrab (display);
 
-  window = gdk_window_lookup_for_display (display, last);
+  window = gdk_x11_window_lookup_for_display (display, last);
 
   if (win_x)
     *win_x = (window) ? xwin_x : -1;
diff --git a/gdk/x11/gdkdevice-xi2.c b/gdk/x11/gdkdevice-xi2.c
index 522eda9..0af7a7e 100644
--- a/gdk/x11/gdkdevice-xi2.c
+++ b/gdk/x11/gdkdevice-xi2.c
@@ -357,10 +357,10 @@ gdk_device_xi2_query_state (GdkDevice        *device,
     }
 
   if (root_window)
-    *root_window = gdk_window_lookup_for_display (display, xroot_window);
+    *root_window = gdk_x11_window_lookup_for_display (display, xroot_window);
 
   if (child_window)
-    *child_window = gdk_window_lookup_for_display (display, xchild_window);
+    *child_window = gdk_x11_window_lookup_for_display (display, xchild_window);
 
   if (root_x)
     *root_x = (gint) xroot_x;
@@ -590,7 +590,7 @@ gdk_device_xi2_window_at_position (GdkDevice       *device,
         break;
 
       if (get_toplevel && last != root &&
-          (window = gdk_window_lookup_for_display (display, last)) != NULL &&
+          (window = gdk_x11_window_lookup_for_display (display, last)) != NULL &&
           GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN)
         {
           xwindow = last;
@@ -600,7 +600,7 @@ gdk_device_xi2_window_at_position (GdkDevice       *device,
 
   gdk_x11_display_ungrab (display);
 
-  window = gdk_window_lookup_for_display (display, last);
+  window = gdk_x11_window_lookup_for_display (display, last);
 
   if (win_x)
     *win_x = (window) ? (gint) xwin_x : -1;
diff --git a/gdk/x11/gdkdevicemanager-core.c b/gdk/x11/gdkdevicemanager-core.c
index 7163aa2..b368614 100644
--- a/gdk/x11/gdkdevicemanager-core.c
+++ b/gdk/x11/gdkdevicemanager-core.c
@@ -384,7 +384,7 @@ get_event_window (GdkEventTranslator *translator,
 
   device_manager = GDK_DEVICE_MANAGER (translator);
   display = gdk_device_manager_get_display (device_manager);
-  window = gdk_window_lookup_for_display (display, xevent->xany.window);
+  window = gdk_x11_window_lookup_for_display (display, xevent->xany.window);
 
   /* Apply keyboard grabs to non-native windows */
   if (xevent->type == KeyPress || xevent->type == KeyRelease)
@@ -680,7 +680,7 @@ gdk_device_manager_core_translate_event (GdkEventTranslator *translator,
        *  lookup the corresponding GdkWindow.
        */
       if (xevent->xcrossing.subwindow != None)
-	event->crossing.subwindow = gdk_window_lookup_for_display (display, xevent->xcrossing.subwindow);
+	event->crossing.subwindow = gdk_x11_window_lookup_for_display (display, xevent->xcrossing.subwindow);
       else
 	event->crossing.subwindow = NULL;
 
@@ -724,7 +724,7 @@ gdk_device_manager_core_translate_event (GdkEventTranslator *translator,
        *  lookup the corresponding GdkWindow.
        */
       if (xevent->xcrossing.subwindow != None)
-	event->crossing.subwindow = gdk_window_lookup_for_display (display, xevent->xcrossing.subwindow);
+	event->crossing.subwindow = gdk_x11_window_lookup_for_display (display, xevent->xcrossing.subwindow);
       else
 	event->crossing.subwindow = NULL;
 
diff --git a/gdk/x11/gdkdevicemanager-xi.c b/gdk/x11/gdkdevicemanager-xi.c
index 6d65725..9d8c5bc 100644
--- a/gdk/x11/gdkdevicemanager-xi.c
+++ b/gdk/x11/gdkdevicemanager-xi.c
@@ -104,7 +104,7 @@ window_input_info_filter (GdkXEvent *xevent,
   xev = (XEvent *) xevent;
 
   display = gdk_device_manager_get_display (device_manager);
-  window = gdk_window_lookup_for_display (display, xev->xany.window);
+  window = gdk_x11_window_lookup_for_display (display, xev->xany.window);
 
   if (window && xev->type == ConfigureNotify)
     gdk_device_xi_update_window_info (window);
@@ -421,7 +421,7 @@ gdk_device_manager_xi_translate_event (GdkEventTranslator *translator,
   if (!device)
     return FALSE;
 
-  window = gdk_window_lookup_for_display (display, xevent->xany.window);
+  window = gdk_x11_window_lookup_for_display (display, xevent->xany.window);
 
   if (!window)
     return FALSE;
diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c
index f692ff5..177926a 100644
--- a/gdk/x11/gdkdevicemanager-xi2.c
+++ b/gdk/x11/gdkdevicemanager-xi2.c
@@ -894,7 +894,7 @@ get_event_window (GdkEventTranslator *translator,
       {
         XIDeviceEvent *xev = (XIDeviceEvent *) ev;
 
-        window = gdk_window_lookup_for_display (display, xev->event);
+        window = gdk_x11_window_lookup_for_display (display, xev->event);
 
         /* Apply keyboard grabs to non-native windows */
         if (ev->evtype == XI_KeyPress || ev->evtype == XI_KeyRelease)
@@ -926,7 +926,7 @@ get_event_window (GdkEventTranslator *translator,
       {
         XIEnterEvent *xev = (XIEnterEvent *) ev;
 
-        window = gdk_window_lookup_for_display (display, xev->event);
+        window = gdk_x11_window_lookup_for_display (display, xev->event);
       }
       break;
     }
@@ -1188,7 +1188,7 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator,
         event->crossing.focus = xev->focus;
 
         event->crossing.window = window;
-        event->crossing.subwindow = gdk_window_lookup_for_display (display, xev->child);
+        event->crossing.subwindow = gdk_x11_window_lookup_for_display (display, xev->child);
 
         device = g_hash_table_lookup (device_manager->id_table,
                                       GINT_TO_POINTER (xev->deviceid));
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index 113d61f..8dfb40a 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -368,7 +368,7 @@ get_event_window (GdkEventTranslator *translator,
       xwindow = xevent->xany.window;
     }
 
-  return gdk_window_lookup_for_display (display, xwindow);
+  return gdk_x11_window_lookup_for_display (display, xwindow);
 }
 
 static gboolean
diff --git a/gdk/x11/gdkdisplay-x11.h b/gdk/x11/gdkdisplay-x11.h
index 3f345de..f682ca4 100644
--- a/gdk/x11/gdkdisplay-x11.h
+++ b/gdk/x11/gdkdisplay-x11.h
@@ -41,7 +41,6 @@ typedef struct _GdkDisplayX11Class GdkDisplayX11Class;
 #define GDK_TYPE_DISPLAY_X11              (_gdk_display_x11_get_type())
 #define GDK_DISPLAY_X11(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DISPLAY_X11, GdkDisplayX11))
 #define GDK_DISPLAY_X11_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DISPLAY_X11, GdkDisplayX11Class))
-#define GDK_IS_DISPLAY_X11(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DISPLAY_X11))
 #define GDK_IS_DISPLAY_X11_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DISPLAY_X11))
 #define GDK_DISPLAY_X11_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DISPLAY_X11, GdkDisplayX11Class))
 
diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c
index ae8d2b8..0cba36a 100644
--- a/gdk/x11/gdkdnd-x11.c
+++ b/gdk/x11/gdkdnd-x11.c
@@ -988,8 +988,8 @@ motif_find_drag_window (GdkDisplay *display,
        */
       if (display_x11->motif_drag_window)
 	{
-	  display_x11->motif_drag_gdk_window = 
-	    gdk_window_foreign_new_for_display (display, display_x11->motif_drag_window);
+	  display_x11->motif_drag_gdk_window =
+	    gdk_x11_window_foreign_new_for_display (display, display_x11->motif_drag_window);
 	  gdk_window_add_filter (display_x11->motif_drag_gdk_window,
 				 motif_drag_window_filter,
 				 NULL);
@@ -1668,12 +1668,12 @@ motif_drag_context_new (GdkWindow *dest_window,
   context->protocol = GDK_DRAG_PROTO_MOTIF;
   context->is_source = FALSE;
 
-  context->source_window = gdk_window_lookup_for_display (display, source_window);
+  context->source_window = gdk_x11_window_lookup_for_display (display, source_window);
   if (context->source_window)
     g_object_ref (context->source_window);
   else
     {
-      context->source_window = gdk_window_foreign_new_for_display (display, source_window);
+      context->source_window = gdk_x11_window_foreign_new_for_display (display, source_window);
       if (!context->source_window)
 	{
 	  g_object_unref (context_x11);
@@ -2843,12 +2843,12 @@ xdnd_enter_filter (GdkXEvent *xev,
   device_manager = gdk_display_get_device_manager (display);
   gdk_drag_context_set_device (context, gdk_device_manager_get_client_pointer (device_manager));
 
-  context->source_window = gdk_window_lookup_for_display (display, source_window);
+  context->source_window = gdk_x11_window_lookup_for_display (display, source_window);
   if (context->source_window)
     g_object_ref (context->source_window);
   else
     {
-      context->source_window = gdk_window_foreign_new_for_display (display, source_window);
+      context->source_window = gdk_x11_window_foreign_new_for_display (display, source_window);
       if (!context->source_window)
 	{
 	  g_object_unref (context);
@@ -3158,7 +3158,7 @@ _gdk_x11_display_get_drag_protocol (GdkDisplay      *display,
   base_precache_atoms (display);
 
   /* Check for a local drag */
-  window = gdk_window_lookup_for_display (display, xid);
+  window = gdk_x11_window_lookup_for_display (display, xid);
   if (window && gdk_window_get_window_type (window) != GDK_WINDOW_FOREIGN)
     {
       if (g_object_get_data (G_OBJECT (window), "gdk-dnd-registered") != NULL)
@@ -3273,11 +3273,11 @@ gdk_drag_context_x11_find_window (GdkDragContext  *context,
 
       if (recipient != None)
         {
-          dest_window = gdk_window_lookup_for_display (display, recipient);
+          dest_window = gdk_x11_window_lookup_for_display (display, recipient);
           if (dest_window)
             g_object_ref (dest_window);
           else
-            dest_window = gdk_window_foreign_new_for_display (display, recipient);
+            dest_window = gdk_x11_window_foreign_new_for_display (display, recipient);
         }
       else
         dest_window = NULL;
diff --git a/gdk/x11/gdkeventsource.c b/gdk/x11/gdkeventsource.c
index 560e4a8..6d7d856 100644
--- a/gdk/x11/gdkeventsource.c
+++ b/gdk/x11/gdkeventsource.c
@@ -104,7 +104,7 @@ gdk_event_source_get_filter_window (GdkEventSource *event_source,
 {
   GdkWindow *window;
 
-  window = gdk_window_lookup_for_display (event_source->display,
+  window = gdk_x11_window_lookup_for_display (event_source->display,
                                           xevent->xany.window);
 
   if (window && !GDK_IS_WINDOW (window))
diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c
index 95cfecb..8ff0859 100644
--- a/gdk/x11/gdkscreen-x11.c
+++ b/gdk/x11/gdkscreen-x11.c
@@ -1023,8 +1023,8 @@ gdk_screen_x11_get_active_window (GdkScreen *screen)
 
           if (window != None)
             {
-              ret = gdk_window_foreign_new_for_display (screen_x11->display,
-                                                        *(GdkNativeWindow *) data);
+              ret = gdk_x11_window_foreign_new_for_display (screen_x11->display,
+                                                        *(Window *) data);
             }
         }
     }
@@ -1071,8 +1071,8 @@ gdk_screen_x11_get_window_stack (GdkScreen *screen)
 
           for (i = 0; i < nitems_return; i++)
             {
-              win = gdk_window_foreign_new_for_display (screen_x11->display,
-                                                        (GdkNativeWindow)stack[i]);
+              win = gdk_x11_window_foreign_new_for_display (screen_x11->display,
+                                                            (Window)stack[i]);
 
               if (win != NULL)
                 ret = g_list_append (ret, win);
@@ -1507,7 +1507,7 @@ gdk_xsettings_watch_cb (Window   window,
   GdkWindow *gdkwin;
   GdkScreen *screen = cb_data;
 
-  gdkwin = gdk_window_lookup_for_display (gdk_screen_get_display (screen), window);
+  gdkwin = gdk_x11_window_lookup_for_display (gdk_screen_get_display (screen), window);
 
   if (is_start)
     {
@@ -1515,7 +1515,7 @@ gdk_xsettings_watch_cb (Window   window,
 	g_object_ref (gdkwin);
       else
 	{
-	  gdkwin = gdk_window_foreign_new_for_display (gdk_screen_get_display (screen), window);
+	  gdkwin = gdk_x11_window_foreign_new_for_display (gdk_screen_get_display (screen), window);
 	  
 	  /* gdk_window_foreign_new_for_display() can fail and return NULL if the
 	   * window has already been destroyed.
diff --git a/gdk/x11/gdkselection-x11.c b/gdk/x11/gdkselection-x11.c
index 74d17c4..49cdf3a 100644
--- a/gdk/x11/gdkselection-x11.c
+++ b/gdk/x11/gdkselection-x11.c
@@ -221,7 +221,7 @@ gdk_selection_owner_get_for_display (GdkDisplay *display,
   if (xwindow == None)
     return NULL;
 
-  return gdk_window_lookup_for_display (display, xwindow);
+  return gdk_x11_window_lookup_for_display (display, xwindow);
 }
 
 void
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index 287a5bc..e7af2aa 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -848,30 +848,28 @@ x_event_mask_to_gdk_event_mask (long mask)
 }
 
 /**
- * gdk_window_foreign_new_for_display:
+ * gdk_x11_window_foreign_new_for_display:
  * @display: the #GdkDisplay where the window handle comes from.
- * @anid: a native window handle.
- * 
+ * @window: an XLib <type>Window</type>
+ *
  * Wraps a native window in a #GdkWindow.
+ *
  * This may fail if the window has been destroyed. If the window
- * was already known to GDK, a new reference to the existing 
+ * 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: (transfer full): 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
- **/
+ * Since: 3.0
+ */
 GdkWindow *
-gdk_window_foreign_new_for_display (GdkDisplay     *display,
-				    GdkNativeWindow anid)
+gdk_x11_window_foreign_new_for_display (GdkDisplay *display,
+                                        Window      window)
 {
   GdkScreen *screen;
-  GdkWindow *window;
+  GdkWindow *win;
   GdkWindowImplX11 *impl;
   GdkDisplayX11 *display_x11;
   XWindowAttributes attrs;
@@ -884,90 +882,88 @@ gdk_window_foreign_new_for_display (GdkDisplay     *display,
 
   display_x11 = GDK_DISPLAY_X11 (display);
 
-  if ((window = gdk_xid_table_lookup_for_display (display, anid)) != NULL)
-    return g_object_ref (window);
+  if ((win = gdk_xid_table_lookup_for_display (display, window)) != NULL)
+    return g_object_ref (win);
 
-  gdk_error_trap_push ();
-  result = XGetWindowAttributes (display_x11->xdisplay, anid, &attrs);
-  if (gdk_error_trap_pop () || !result)
+  gdk_x11_display_error_trap_push (display);
+  result = XGetWindowAttributes (display_x11->xdisplay, window, &attrs);
+  if (gdk_x11_display_error_trap_pop (display) || !result)
     return NULL;
 
-  /* FIXME: This is pretty expensive. Maybe the caller should supply
-   *        the parent */
-  gdk_error_trap_push ();
-  result = XQueryTree (display_x11->xdisplay, anid, &root, &parent, &children, &nchildren);
-  if (gdk_error_trap_pop () || !result)
+  /* FIXME: This is pretty expensive.
+   * Maybe the caller should supply the parent
+   */
+  gdk_x11_display_error_trap_push (display);
+  result = XQueryTree (display_x11->xdisplay, window, &root, &parent, &children, &nchildren);
+  if (gdk_x11_display_error_trap_pop (display) || !result)
     return NULL;
 
   if (children)
     XFree (children);
-  
+
   screen = _gdk_x11_display_screen_for_xrootwin (display, root);
 
-  window = g_object_new (GDK_TYPE_WINDOW, NULL);
+  win = g_object_new (GDK_TYPE_WINDOW, NULL);
+  win->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_X11, NULL);
+  win->impl_window = win;
+  win->visual = gdk_x11_screen_lookup_visual (screen,
+                                              XVisualIDFromVisual (attrs.visual));
 
-  window->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_X11, NULL);
-  window->impl_window = window;
-  window->visual = gdk_x11_screen_lookup_visual (screen,
-                                                  XVisualIDFromVisual (attrs.visual));
+  impl = GDK_WINDOW_IMPL_X11 (win->impl);
+  impl->wrapper = win;
 
-  impl = GDK_WINDOW_IMPL_X11 (window->impl);
-  impl->wrapper = window;
-  
-  window->parent = gdk_xid_table_lookup_for_display (display, parent);
-  
-  if (!window->parent || GDK_WINDOW_TYPE (window->parent) == GDK_WINDOW_FOREIGN)
-    window->parent = gdk_screen_get_root_window (screen);
-  
-  window->parent->children = g_list_prepend (window->parent->children, window);
+  win->parent = gdk_xid_table_lookup_for_display (display, parent);
+
+  if (!win->parent || GDK_WINDOW_TYPE (win->parent) == GDK_WINDOW_FOREIGN)
+    win->parent = gdk_screen_get_root_window (screen);
 
-  impl->xid = anid;
+  win->parent->children = g_list_prepend (win->parent->children, win);
 
-  window->x = attrs.x;
-  window->y = attrs.y;
-  window->width = attrs.width;
-  window->height = attrs.height;
-  window->window_type = GDK_WINDOW_FOREIGN;
-  window->destroyed = FALSE;
+  impl->xid = window;
 
-  window->event_mask = x_event_mask_to_gdk_event_mask (attrs.your_event_mask);
+  win->x = attrs.x;
+  win->y = attrs.y;
+  win->width = attrs.width;
+  win->height = attrs.height;
+  win->window_type = GDK_WINDOW_FOREIGN;
+  win->destroyed = FALSE;
+
+  win->event_mask = x_event_mask_to_gdk_event_mask (attrs.your_event_mask);
 
   if (attrs.map_state == IsUnmapped)
-    window->state = GDK_WINDOW_STATE_WITHDRAWN;
+    win->state = GDK_WINDOW_STATE_WITHDRAWN;
   else
-    window->state = 0;
-  window->viewable = TRUE;
+    win->state = 0;
+  win->viewable = TRUE;
 
-  window->depth = attrs.depth;
-  
-  g_object_ref (window);
-  _gdk_xid_table_insert (display, &GDK_WINDOW_XID (window), window);
+  win->depth = attrs.depth;
+
+  g_object_ref (win);
+  _gdk_xid_table_insert (display, &GDK_WINDOW_XID (win), win);
 
   /* Update the clip region, etc */
-  _gdk_window_update_size (window);
+  _gdk_window_update_size (win);
 
-  return window;
+  return win;
 }
 
 /**
- * gdk_window_lookup_for_display:
+ * gdk_x11_window_lookup_for_display:
  * @display: the #GdkDisplay corresponding to the window handle
- * @anid: a native window handle.
+ * @window: an XLib <type>Window</type>
  *
  * Looks up the #GdkWindow that wraps the given native window handle.
  *
- * For example in the X backend, a native window handle is an Xlib
- * <type>XID</type>.
- *
  * Return value: (transfer none): the #GdkWindow wrapper for the native
  *    window, or %NULL if there is none.
  *
- * Since: 2.2
- **/
+ * Since: 3.0
+ */
 GdkWindow *
-gdk_window_lookup_for_display (GdkDisplay *display, GdkNativeWindow anid)
+gdk_x11_window_lookup_for_display (GdkDisplay *display,
+                                   Window      window)
 {
-  return (GdkWindow*) gdk_xid_table_lookup_for_display (display, anid);
+  return (GdkWindow*) gdk_xid_table_lookup_for_display (display, window);
 }
 
 static void
@@ -1008,11 +1004,11 @@ gdk_x11_window_destroy (GdkWindow *window,
 {
   GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
   GdkToplevelX11 *toplevel;
-  
+
   g_return_if_fail (GDK_IS_WINDOW (window));
 
   _gdk_selection_window_destroyed (window);
-  
+
   toplevel = _gdk_x11_window_get_toplevel (window);
   if (toplevel)
     gdk_toplevel_x11_free_contents (GDK_WINDOW_DISPLAY (window), toplevel);
@@ -1021,13 +1017,11 @@ gdk_x11_window_destroy (GdkWindow *window,
     {
       cairo_surface_finish (impl->cairo_surface);
       cairo_surface_set_user_data (impl->cairo_surface, &gdk_x11_cairo_key,
-				   NULL, NULL);
+                                   NULL, NULL);
     }
 
   if (!recursing && !foreign_destroy)
-    {
-      XDestroyWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
-    }
+    XDestroyWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
 }
 
 static cairo_surface_t *
@@ -1049,28 +1043,28 @@ gdk_x11_window_destroy_foreign (GdkWindow *window)
    * it a delete event, as if we were a WM
    */
   XClientMessageEvent xclient;
-  
-  gdk_error_trap_push ();
+  GdkDisplay *display;
+
+  display = GDK_WINDOW_DISPLAY (window);
+  gdk_x11_display_error_trap_push (display);
   gdk_window_hide (window);
   gdk_window_reparent (window, NULL, 0, 0);
-  
+
   memset (&xclient, 0, sizeof (xclient));
   xclient.type = ClientMessage;
   xclient.window = GDK_WINDOW_XID (window);
-  xclient.message_type = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
-							       "WM_PROTOCOLS");
+  xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "WM_PROTOCOLS");
   xclient.format = 32;
-  xclient.data.l[0] = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
-							    "WM_DELETE_WINDOW");
+  xclient.data.l[0] = gdk_x11_get_xatom_by_name_for_display (display, "WM_DELETE_WINDOW");
   xclient.data.l[1] = CurrentTime;
   xclient.data.l[2] = 0;
   xclient.data.l[3] = 0;
   xclient.data.l[4] = 0;
   
   XSendEvent (GDK_WINDOW_XDISPLAY (window),
-	      GDK_WINDOW_XID (window),
-	      False, 0, (XEvent *)&xclient);
-  gdk_error_trap_pop_ignored ();
+              GDK_WINDOW_XID (window),
+              False, 0, (XEvent *)&xclient);
+  gdk_x11_display_error_trap_pop_ignored (display);
 }
 
 static GdkWindow *
diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h
index 7e5dd1b..15b5e50 100644
--- a/gdk/x11/gdkx.h
+++ b/gdk/x11/gdkx.h
@@ -95,6 +95,7 @@ gint     gdk_x11_get_default_screen       (void);
  */
 #define GDK_CURSOR_XCURSOR(cursor)    (gdk_x11_cursor_get_xcursor (cursor))
 
+#define GDK_IS_DISPLAY_X11(object)   (G_TYPE_CHECK_INSTANCE_TYPE ((object), g_type_from_name ("GdkDisplayX11")))
 
 #ifdef GDK_COMPILATION
 
@@ -250,6 +251,11 @@ void        gdk_x11_register_standard_event_type (GdkDisplay *display,
 
 void        gdk_x11_set_sm_client_id (const gchar *sm_client_id);
 
+GdkWindow  *gdk_x11_window_foreign_new_for_display (GdkDisplay *display,
+                                                    Window      window);
+GdkWindow  *gdk_x11_window_lookup_for_display      (GdkDisplay *display,
+                                                    Window      window);
+
 G_END_DECLS
 
 #endif /* __GDK_X_H__ */
diff --git a/gtk/gtkplug-x11.c b/gtk/gtkplug-x11.c
index df98e93..3f4e678 100644
--- a/gtk/gtkplug-x11.c
+++ b/gtk/gtkplug-x11.c
@@ -315,7 +315,7 @@ _gtk_plug_windowing_filter_func (GdkXEvent *gdk_xevent,
 
 	    GTK_NOTE (PLUGSOCKET, g_message ("GtkPlug: start of embedding"));
 
-            priv->socket_window = gdk_window_lookup_for_display (display, xre->parent);
+            priv->socket_window = gdk_x11_window_lookup_for_display (display, xre->parent);
             if (priv->socket_window)
 	      {
 		gpointer user_data = NULL;
@@ -332,7 +332,7 @@ _gtk_plug_windowing_filter_func (GdkXEvent *gdk_xevent,
 	      }
 	    else
 	      {
-		priv->socket_window = gdk_window_foreign_new_for_display (display, xre->parent);
+		priv->socket_window = gdk_x11_window_foreign_new_for_display (display, xre->parent);
 		if (!priv->socket_window) /* Already gone */
 		  break; /* FIXME: shouldn't this unref the plug? i.e. "goto done;" instead */
 	      }
diff --git a/gtk/gtkplug.c b/gtk/gtkplug.c
index d3aacab..6d8759f 100644
--- a/gtk/gtkplug.c
+++ b/gtk/gtkplug.c
@@ -36,6 +36,10 @@
 #include "gtkwidgetprivate.h"
 #include "gtkwindow.h"
 
+#ifdef GDK_WINDOWING_X11
+#include "x11/gdkx.h"
+#endif
+
 /**
  * SECTION:gtkplug
  * @Short_description: Toplevel for embedding into other processes
@@ -512,7 +516,13 @@ gtk_plug_construct_for_display (GtkPlug         *plug,
     {
       gpointer user_data = NULL;
 
-      priv->socket_window = gdk_window_lookup_for_display (display, socket_id);
+#ifdef GDK_WINDOWING_X11
+      if (GDK_IS_DISPLAY_X11 (display))
+        priv->socket_window = gdk_x11_window_lookup_for_display (display, socket_id);
+      else
+#endif
+        priv->socket_window = NULL;
+
       if (priv->socket_window)
 	{
 	  gdk_window_get_user_data (priv->socket_window, &user_data);
@@ -531,7 +541,10 @@ gtk_plug_construct_for_display (GtkPlug         *plug,
 	    g_object_ref (priv->socket_window);
 	}
       else
-	priv->socket_window = gdk_window_foreign_new_for_display (display, socket_id);
+#ifdef GDK_WINDOWING_X11
+      if (GDK_IS_DISPLAY_X11 (display))
+        priv->socket_window = gdk_x11_window_foreign_new_for_display (display, socket_id);
+#endif
 
       if (priv->socket_window) {
 	g_signal_emit (plug, plug_signals[EMBEDDED], 0);
diff --git a/gtk/gtkselection.c b/gtk/gtkselection.c
index fd8058d..04908a7 100644
--- a/gtk/gtkselection.c
+++ b/gtk/gtkselection.c
@@ -2263,20 +2263,20 @@ _gtk_selection_request (GtkWidget *widget,
   info = g_slice_new (GtkIncrInfo);
 
   g_object_ref (widget);
-  
+
   info->selection = event->selection;
   info->num_incrs = 0;
-  
+
   /* Create GdkWindow structure for the requestor */
-  
-  info->requestor = gdk_window_lookup_for_display (display,
-						   event->requestor);
-  if (!info->requestor)
-    info->requestor = gdk_window_foreign_new_for_display (display,
-							  event->requestor);
-  
+
+#ifdef GDK_WINDOWING_X11
+  if (GDK_IS_DISPLAY_X11 (display))
+    info->requestor = gdk_x11_window_foreign_new_for_display (display, event->requestor);
+  else
+#endif
+    info->requestor = NULL;
+
   /* Determine conversions we need to perform */
-  
   if (event->target == gtk_selection_atoms[MULTIPLE])
     {
       GdkAtom  type;
diff --git a/gtk/gtksocket.c b/gtk/gtksocket.c
index b50d1c8..c244938 100644
--- a/gtk/gtksocket.c
+++ b/gtk/gtksocket.c
@@ -44,6 +44,10 @@
 #include "gtkintl.h"
 #include "gtkwidgetprivate.h"
 
+#ifdef GDK_WINDOWING_X11
+#include "x11/gdkx.h"
+#endif
+
 
 /**
  * SECTION:gtksocket
@@ -866,8 +870,13 @@ _gtk_socket_add_window (GtkSocket       *socket,
   GtkWidget *widget = GTK_WIDGET (socket);
   GdkDisplay *display = gtk_widget_get_display (widget);
   gpointer user_data = NULL;
-  
-  socket->plug_window = gdk_window_lookup_for_display (display, xid);
+
+#ifdef GDK_WINDOWING_X11
+  if (GDK_IS_DISPLAY_X11 (display))
+    socket->plug_window = gdk_x11_window_lookup_for_display (display, xid);
+  else
+#endif
+    socket->plug_window = NULL;
 
   if (socket->plug_window)
     {
@@ -875,22 +884,22 @@ _gtk_socket_add_window (GtkSocket       *socket,
       gdk_window_get_user_data (socket->plug_window, &user_data);
     }
 
-  if (user_data)		/* A widget's window in this process */
+  if (user_data) /* A widget's window in this process */
     {
       GtkWidget *child_widget = user_data;
 
       if (!GTK_IS_PLUG (child_widget))
-	{
-	  g_warning (G_STRLOC ": Can't add non-GtkPlug to GtkSocket");
-	  socket->plug_window = NULL;
-	  gdk_error_trap_pop_ignored ();
-	  
-	  return;
-	}
+        {
+          g_warning (G_STRLOC ": Can't add non-GtkPlug to GtkSocket");
+          socket->plug_window = NULL;
+          gdk_error_trap_pop_ignored ();
+
+          return;
+        }
 
       _gtk_plug_add_to_socket (GTK_PLUG (child_widget), socket);
     }
-  else				/* A foreign window */
+  else  /* A foreign window */
     {
       GtkWidget *toplevel;
       GdkDragProtocol protocol;
@@ -898,8 +907,11 @@ _gtk_socket_add_window (GtkSocket       *socket,
       gdk_error_trap_push ();
 
       if (!socket->plug_window)
-	{  
-	  socket->plug_window = gdk_window_foreign_new_for_display (display, xid);
+        {
+#ifdef GDK_WINDOWING_X11
+          if (GDK_IS_DISPLAY_X11 (display))
+            socket->plug_window = gdk_x11_window_foreign_new_for_display (display, xid);
+#endif
 	  if (!socket->plug_window) /* was deleted before we could get it */
 	    {
 	      gdk_error_trap_pop_ignored ();
diff --git a/gtk/gtktrayicon-x11.c b/gtk/gtktrayicon-x11.c
index 4689d3c..d814cf8 100644
--- a/gtk/gtktrayicon-x11.c
+++ b/gtk/gtktrayicon-x11.c
@@ -254,8 +254,8 @@ gtk_tray_icon_clear_manager_window (GtkTrayIcon *icon)
     {
       GdkWindow *gdkwin;
 
-      gdkwin = gdk_window_lookup_for_display (display,
-                                              icon->priv->manager_window);
+      gdkwin = gdk_x11_window_lookup_for_display (display,
+                                                  icon->priv->manager_window);
 
       gdk_window_remove_filter (gdkwin, gtk_tray_icon_manager_filter, icon);
 
@@ -767,12 +767,12 @@ gtk_tray_icon_update_manager_window (GtkTrayIcon *icon)
       GdkWindow *gdkwin;
 
       GTK_NOTE (PLUGSOCKET,
-		g_print ("GtkStatusIcon %p: is being managed by window %lx\n",
-				icon, (gulong) icon->priv->manager_window));
+        g_print ("GtkStatusIcon %p: is being managed by window %lx\n",
+                 icon, (gulong) icon->priv->manager_window));
+
+      gdkwin = gdk_x11_window_lookup_for_display (display,
+                                                  icon->priv->manager_window);
 
-      gdkwin = gdk_window_lookup_for_display (display,
-					      icon->priv->manager_window);
-      
       gdk_window_add_filter (gdkwin, gtk_tray_icon_manager_filter, icon);
 
       gtk_tray_icon_get_orientation_property (icon);



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