]> Pileus Git - ~andy/gtk/blobdiff - gdk/x11/gdkxid.c
Change FSF Address
[~andy/gtk] / gdk / x11 / gdkxid.c
index c53ee38355b46a576d2a30a4aa5966883dd3eea4..5eaa36af1e8cc0e622bc877b0f357c83fcaf8866 100644 (file)
@@ -12,9 +12,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
 /*
  */
 
 #include "config.h"
-#include "gdkx.h"
+
 #include "gdkprivate-x11.h"
 #include "gdkdisplay-x11.h"
-#include "gdkalias.h"
-#include <stdio.h>
 
-static guint     gdk_xid_hash  (XID *xid);
-static gboolean  gdk_xid_equal (XID *a,
-                               XID *b);
+#include <stdio.h>
 
+static guint
+gdk_xid_hash (XID *xid)
+{
+  return *xid;
+}
 
-/* The 3 high bits of XIDs are unused. We use one to mark fonts, 
- * since we must be able to skip fonts when iterating over all XIDs.
- */
-#define XID_FONT_BIT (1<<31)
+static gboolean
+gdk_xid_equal (XID *a, XID *b)
+{
+  return (*a == *b);
+}
 
 void
-_gdk_xid_table_insert (GdkDisplay *display,
-                      XID        *xid,
-                      gpointer    data)
+_gdk_x11_display_add_window (GdkDisplay *display,
+                             XID        *xid,
+                             GdkWindow  *data)
 {
-  GdkDisplayX11 *display_x11;
+  GdkX11Display *display_x11;
 
   g_return_if_fail (xid != NULL);
   g_return_if_fail (GDK_IS_DISPLAY (display));
 
-  display_x11 = GDK_DISPLAY_X11 (display);
+  display_x11 = GDK_X11_DISPLAY (display);
 
   if (!display_x11->xid_ht)
     display_x11->xid_ht = g_hash_table_new ((GHashFunc) gdk_xid_hash,
-                                           (GEqualFunc) gdk_xid_equal);
+                                            (GEqualFunc) gdk_xid_equal);
 
   if (g_hash_table_lookup (display_x11->xid_ht, xid))
     g_warning ("XID collision, trouble ahead");
@@ -64,79 +64,45 @@ _gdk_xid_table_insert (GdkDisplay *display,
 }
 
 void
-_gdk_xid_table_remove (GdkDisplay *display,
-                      XID         xid)
+_gdk_x11_display_remove_window (GdkDisplay *display,
+                                XID         xid)
 {
-  GdkDisplayX11 *display_x11;
+  GdkX11Display *display_x11;
 
   g_return_if_fail (GDK_IS_DISPLAY (display));
 
-  display_x11 = GDK_DISPLAY_X11 (display);
+  display_x11 = GDK_X11_DISPLAY (display);
 
   if (display_x11->xid_ht)
     g_hash_table_remove (display_x11->xid_ht, &xid);
 }
 
 /**
- * gdk_xid_table_lookup_for_display:
- * @display: the #GdkDisplay.
- * @xid: an X id.
+ * gdk_x11_window_lookup_for_display:
+ * @display: (type GdkX11Window): the #GdkDisplay corresponding to the
+ *           window handle
+ * @window: an XLib <type>Window</type>
  *
- * Returns the GDK object associated with the given X id.
+ * Looks up the #GdkWindow that wraps the given native window handle.
  *
- * Return value: the associated Gdk object, which may be a #GdkPixmap,
- *     a #GdkWindow or a #GdkFont or %NULL if no object is associated
- *     with the X id.
+ * Return value: (transfer none): the #GdkWindow wrapper for the native
+ *    window, or %NULL if there is none.
  *
- * Since: 2.2
+ * Since: 2.24
  */
-gpointer
-gdk_xid_table_lookup_for_display (GdkDisplay  *display,
-                                 XID          xid)
+GdkWindow *
+gdk_x11_window_lookup_for_display (GdkDisplay *display,
+                                   Window      window)
 {
-  GdkDisplayX11 *display_x11;
-  gpointer data = NULL;
-  
-  g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
-  
-  display_x11 = GDK_DISPLAY_X11 (display);
-
-  if (display_x11->xid_ht)
-    data = g_hash_table_lookup (display_x11->xid_ht, &xid);
-  
-  return data;
-}
+  GdkX11Display *display_x11;
+  GdkWindow *data = NULL;
 
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
 
-/**
- * gdk_xid_table_lookup:
- * @xid: an X id.
- *
- * Returns the Gdk object associated with the given X id for the default
- * display.
- *
- * Return value: the associated Gdk object, which may be a #GdkPixmap,
- *     a #GdkWindow or a #GdkFont or %NULL if no object is associated
- *     with the X id.
- */
-gpointer
-gdk_xid_table_lookup (XID xid)
-{
-  return gdk_xid_table_lookup_for_display (gdk_display_get_default (), xid);
-}
+  display_x11 = GDK_X11_DISPLAY (display);
 
-static guint
-gdk_xid_hash (XID *xid)
-{
-  return *xid;
-}
+  if (display_x11->xid_ht)
+    data = g_hash_table_lookup (display_x11->xid_ht, &window);
 
-static gboolean
-gdk_xid_equal (XID *a,
-              XID *b)
-{
-  return ((*a & ~XID_FONT_BIT) == (*b & ~XID_FONT_BIT));
+  return data;
 }
-
-#define __GDK_XID_C__
-#include "gdkaliasdef.c"