[gtk+/gtk-2-24] Deprecate foreign window apis



commit 2f8c78ddc568ef75ef416bc2b45b049fa9e2a5d5
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Dec 17 00:34:25 2010 -0500

    Deprecate foreign window apis
    
    And add x11- and win32-specific apis for these at the same time

 docs/reference/gdk/gdk-sections.txt |    3 +
 gdk/gdk.symbols                     |    2 +
 gdk/gdkwindow.h                     |    2 +
 gdk/win32/gdkwin32.h                |    5 ++
 gdk/win32/gdkwindow-win32.c         |   14 ++++++
 gdk/x11/gdkwindow-x11.c             |   89 +++++++++++++++++++++++++++-------
 gdk/x11/gdkx.h                      |    6 ++
 7 files changed, 102 insertions(+), 19 deletions(-)
---
diff --git a/docs/reference/gdk/gdk-sections.txt b/docs/reference/gdk/gdk-sections.txt
index c8608be..c3d6040 100644
--- a/docs/reference/gdk/gdk-sections.txt
+++ b/docs/reference/gdk/gdk-sections.txt
@@ -1407,6 +1407,9 @@ gdk_x11_get_xatom_by_name
 gdk_x11_get_xatom_by_name_for_display
 gdk_x11_get_xatom_name
 gdk_x11_get_xatom_name_for_display
+gdk_x11_set_sm_client_id
+gdk_x11_window_foreign_new_for_display
+gdk_x11_window_lookup_for_display
 
 <SUBSECTION Private>
 gdk_display
diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols
index 92c9014..2356d1d 100644
--- a/gdk/gdk.symbols
+++ b/gdk/gdk.symbols
@@ -1353,6 +1353,8 @@ gdkx_visual_get
 #if IN_FILE(__GDK_WINDOW_X11_C__)
 gdk_x11_window_set_user_time
 gdk_x11_window_move_to_current_desktop
+gdk_x11_window_foreign_new_for_display
+gdk_x11_window_lookup_for_display
 #endif
 
 #if IN_FILE(__GDK_XID_C__)
diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h
index e2ac52d..8e2c0fc 100644
--- a/gdk/gdkwindow.h
+++ b/gdk/gdkwindow.h
@@ -475,6 +475,7 @@ gboolean gdk_window_set_static_gravities (GdkWindow *window,
 					  gboolean   use_static);   
 
 /* Functions to create/lookup windows from their native equivalents */ 
+#if !defined(GDK_DISABLE_DEPRECATED) || defined(GDK_COMPILATION)
 #ifndef GDK_MULTIHEAD_SAFE
 GdkWindow*    gdk_window_foreign_new (GdkNativeWindow anid);
 GdkWindow*    gdk_window_lookup      (GdkNativeWindow anid);
@@ -483,6 +484,7 @@ GdkWindow    *gdk_window_foreign_new_for_display (GdkDisplay      *display,
 						  GdkNativeWindow  anid);
 GdkWindow*    gdk_window_lookup_for_display (GdkDisplay      *display,
 					     GdkNativeWindow  anid);
+#endif
 
 
 /* GdkWindow */
diff --git a/gdk/win32/gdkwin32.h b/gdk/win32/gdkwin32.h
index 7042d99..1f03097 100644
--- a/gdk/win32/gdkwin32.h
+++ b/gdk/win32/gdkwin32.h
@@ -117,6 +117,11 @@ GdkDrawable  *gdk_win32_begin_direct_draw_libgtk_only (GdkDrawable *drawable,
 						       gint *y_offset_out);
 void          gdk_win32_end_direct_draw_libgtk_only (gpointer priv_data);
 
+GdkWindow *   gdk_win32_window_foreign_new_for_display (GdkDisplay *display,
+                                                        GdkNativeWindow anid);
+GdkWindow *   gdk_win32_window_lookup_for_display (GdkDisplay *display,
+                                                   GdkNativeWindow anid);
+
 
 G_END_DECLS
 
diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c
index 6c1c32e..7a2ff60 100644
--- a/gdk/win32/gdkwindow-win32.c
+++ b/gdk/win32/gdkwindow-win32.c
@@ -736,6 +736,13 @@ GdkWindow *
 gdk_window_foreign_new_for_display (GdkDisplay      *display,
                                     GdkNativeWindow  anid)
 {
+  return gdk_win32_window_foreign_new_for_display (display, anid);
+}
+
+GdkWindow *
+gdk_win32_window_foreign_new_for_display (GdkDisplay      *display,
+                                          GdkNativeWindow  anid)
+{
   GdkWindow *window;
   GdkWindowObject *private;
   GdkWindowImplWin32 *impl;
@@ -3640,6 +3647,13 @@ GdkWindow *
 gdk_window_lookup_for_display (GdkDisplay      *display,
                                GdkNativeWindow  anid)
 {
+  return gdk_win32_window_lookup_for_display (display, anid);
+}
+
+GdkWindow *
+gdk_win32_window_lookup_for_display (GdkDisplay      *display,
+                                     GdkNativeWindow  anid)
+{
   g_return_val_if_fail (display == _gdk_display, NULL);
 
   return gdk_window_lookup (anid);
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index 175adb6..d84e0e0 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -867,17 +867,43 @@ x_event_mask_to_gdk_event_mask (long mask)
  * For example in the X backend, a native window handle is an Xlib
  * <type>XID</type>.
  * 
- * Return value: a #GdkWindow wrapper for the native window or 
+ * 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
+ *
+ * Deprecated:2.24: Use gdk_x11_window_foreign_new_for_display() or
+ *     equivalent backend-specific API instead
  **/
 GdkWindow *
 gdk_window_foreign_new_for_display (GdkDisplay     *display,
 				    GdkNativeWindow anid)
 {
-  GdkWindow *window;
+}
+
+/**
+ * gdk_x11_window_foreign_new_for_display:
+ * @display: the #GdkDisplay where the window handle comes from.
+ * @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
+ * #GdkWindow is returned.
+ *
+ * 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.24
+ */
+GdkWindow *
+gdk_x11_window_foreign_new_for_display (GdkDisplay *display,
+                                        Window      window)
+{
+  GdkWindow *win;
   GdkWindowObject *private;
   GdkWindowImplX11 *impl;
   GdkDrawableImplX11 *draw_impl;
@@ -892,33 +918,33 @@ 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);
+  result = XGetWindowAttributes (display_x11->xdisplay, window, &attrs);
   if (gdk_error_trap_pop () || !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);
+  result = XQueryTree (display_x11->xdisplay, window, &root, &parent, &children, &nchildren);
   if (gdk_error_trap_pop () || !result)
     return NULL;
 
   if (children)
     XFree (children);
   
-  window = g_object_new (GDK_TYPE_WINDOW, NULL);
+  win = g_object_new (GDK_TYPE_WINDOW, NULL);
 
-  private = (GdkWindowObject *) window;
+  private = (GdkWindowObject *) win;
   private->impl = g_object_new (_gdk_window_impl_get_type (), NULL);
   private->impl_window = private;
 
   impl = GDK_WINDOW_IMPL_X11 (private->impl);
   draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl);
-  draw_impl->wrapper = GDK_DRAWABLE (window);
+  draw_impl->wrapper = GDK_DRAWABLE (win);
   draw_impl->screen = _gdk_x11_display_screen_for_xrootwin (display, root);
   
   private->parent = gdk_xid_table_lookup_for_display (display, parent);
@@ -926,9 +952,9 @@ gdk_window_foreign_new_for_display (GdkDisplay     *display,
   if (!private->parent || GDK_WINDOW_TYPE (private->parent) == GDK_WINDOW_FOREIGN)
     private->parent = (GdkWindowObject *) gdk_screen_get_root_window (draw_impl->screen);
   
-  private->parent->children = g_list_prepend (private->parent->children, window);
+  private->parent->children = g_list_prepend (private->parent->children, win);
 
-  draw_impl->xid = anid;
+  draw_impl->xid = window;
 
   private->x = attrs.x;
   private->y = attrs.y;
@@ -947,13 +973,13 @@ gdk_window_foreign_new_for_display (GdkDisplay     *display,
 
   private->depth = attrs.depth;
   
-  g_object_ref (window);
-  _gdk_xid_table_insert (display, &GDK_WINDOW_XID (window), window);
+  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;
 }
 
 /**
@@ -966,15 +992,37 @@ gdk_window_foreign_new_for_display (GdkDisplay     *display,
  * For example in the X backend, a native window handle is an Xlib
  * <type>XID</type>.
  *
- * Return value: the #GdkWindow wrapper for the native window, 
+ * Return value: the #GdkWindow wrapper for the native window,
  *    or %NULL if there is none.
  *
  * Since: 2.2
+ *
+ * Deprecated:2.24: Use gdk_x11_window_lookup_for_display() instead
  **/
 GdkWindow *
-gdk_window_lookup_for_display (GdkDisplay *display, GdkNativeWindow anid)
+gdk_window_lookup_for_display (GdkDisplay      *display,
+                               GdkNativeWindow  anid)
+{
+  return gdk_x11_window_lookup_for_display (display, anid);
+}
+
+/**
+ * gdk_x11_window_lookup_for_display:
+ * @display: the #GdkDisplay corresponding to the window handle
+ * @window: an XLib <type>Window</type>
+ *
+ * Looks up the #GdkWindow that wraps the given native window handle.
+ *
+ * Return value: the #GdkWindow wrapper for the native window,
+ *    or %NULL if there is none.
+ *
+ * Since: 2.24
+ */
+GdkWindow *
+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);
 }
 
 /**
@@ -986,8 +1034,11 @@ gdk_window_lookup_for_display (GdkDisplay *display, GdkNativeWindow anid)
  * For example in the X backend, a native window handle is an Xlib
  * <type>XID</type>.
  *
- * Return value: the #GdkWindow wrapper for the native window, 
+ * Return value: the #GdkWindow wrapper for the native window,
  *    or %NULL if there is none.
+ *
+ * Deprecated: 2.24: Use gdk_x11_window_lookup_for_display() or equivalent
+ *    backend-specific functionality instead
  **/
 GdkWindow *
 gdk_window_lookup (GdkNativeWindow anid)
diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h
index 17483dd..36d4387 100644
--- a/gdk/x11/gdkx.h
+++ b/gdk/x11/gdkx.h
@@ -219,6 +219,12 @@ G_CONST_RETURN char *gdk_x11_font_get_name     (GdkFont *font);
 
 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__ */



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