1997-11-24 22:37:52 +00:00
|
|
|
/* GDK - The GIMP Drawing Kit
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 11:33:08 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1997-11-24 22:37:52 +00:00
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2000-07-26 11:33:08 +00:00
|
|
|
* Lesser General Public License for more details.
|
1997-11-24 22:37:52 +00:00
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1998-04-13 02:02:47 +00:00
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
1997-11-24 22:37:52 +00:00
|
|
|
*/
|
1999-02-24 07:37:18 +00:00
|
|
|
|
|
|
|
/*
|
2000-07-26 11:33:08 +00:00
|
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
1999-02-24 07:37:18 +00:00
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
* files for a list of changes. These files are distributed with
|
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
|
|
*/
|
|
|
|
|
2004-03-06 03:38:59 +00:00
|
|
|
#include <config.h>
|
2005-03-16 03:17:27 +00:00
|
|
|
#include "gdkx.h"
|
1999-11-08 20:14:59 +00:00
|
|
|
#include "gdkprivate-x11.h"
|
2002-04-25 22:29:14 +00:00
|
|
|
#include "gdkdisplay-x11.h"
|
2005-03-16 03:17:27 +00:00
|
|
|
#include "gdkalias.h"
|
1997-12-18 02:17:14 +00:00
|
|
|
#include <stdio.h>
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2000-11-13 13:15:41 +00:00
|
|
|
static guint gdk_xid_hash (XID *xid);
|
|
|
|
static gboolean gdk_xid_equal (XID *a,
|
|
|
|
XID *b);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
|
2006-01-20 04:35:24 +00:00
|
|
|
/* 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)
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
void
|
2002-04-25 22:29:14 +00:00
|
|
|
_gdk_xid_table_insert (GdkDisplay *display,
|
|
|
|
XID *xid,
|
|
|
|
gpointer data)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2002-04-25 22:29:14 +00:00
|
|
|
GdkDisplayX11 *display_x11;
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
g_return_if_fail (xid != NULL);
|
2002-04-25 22:29:14 +00:00
|
|
|
g_return_if_fail (GDK_IS_DISPLAY (display));
|
|
|
|
|
|
|
|
display_x11 = GDK_DISPLAY_X11 (display);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-04-25 22:29:14 +00:00
|
|
|
if (!display_x11->xid_ht)
|
|
|
|
display_x11->xid_ht = g_hash_table_new ((GHashFunc) gdk_xid_hash,
|
|
|
|
(GEqualFunc) gdk_xid_equal);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-04-25 22:29:14 +00:00
|
|
|
g_hash_table_insert (display_x11->xid_ht, xid, data);
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-04-25 22:29:14 +00:00
|
|
|
_gdk_xid_table_remove (GdkDisplay *display,
|
|
|
|
XID xid)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2002-04-25 22:29:14 +00:00
|
|
|
GdkDisplayX11 *display_x11;
|
|
|
|
|
|
|
|
g_return_if_fail (GDK_IS_DISPLAY (display));
|
|
|
|
|
|
|
|
display_x11 = GDK_DISPLAY_X11 (display);
|
|
|
|
|
2002-09-24 20:20:08 +00:00
|
|
|
if (display_x11->xid_ht)
|
|
|
|
g_hash_table_remove (display_x11->xid_ht, &xid);
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
2002-04-25 22:29:14 +00:00
|
|
|
/**
|
|
|
|
* gdk_xid_table_lookup_for_display:
|
2002-11-28 00:33:17 +00:00
|
|
|
* @display: the #GdkDisplay.
|
|
|
|
* @xid: an X id.
|
2002-04-25 22:29:14 +00:00
|
|
|
*
|
2002-11-28 00:33:17 +00:00
|
|
|
* Returns the GDK object associated with the given X id.
|
|
|
|
*
|
|
|
|
* Returns: a GDK object associated with the given X id.
|
2002-04-25 22:29:14 +00:00
|
|
|
*
|
2002-11-28 00:33:17 +00:00
|
|
|
* Since: 2.2
|
2002-04-25 22:29:14 +00:00
|
|
|
*/
|
1997-11-24 22:37:52 +00:00
|
|
|
gpointer
|
2002-04-25 22:29:14 +00:00
|
|
|
gdk_xid_table_lookup_for_display (GdkDisplay *display,
|
|
|
|
XID xid)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2002-04-25 22:29:14 +00:00
|
|
|
GdkDisplayX11 *display_x11;
|
1998-07-17 14:48:35 +00:00
|
|
|
gpointer data = NULL;
|
2002-04-25 22:29:14 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
|
|
|
|
|
|
|
|
display_x11 = GDK_DISPLAY_X11 (display);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-04-25 22:29:14 +00:00
|
|
|
if (display_x11->xid_ht)
|
|
|
|
data = g_hash_table_lookup (display_x11->xid_ht, &xid);
|
1998-07-17 14:48:35 +00:00
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2002-10-22 22:11:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gdk_xid_table_lookup:
|
|
|
|
* @xid: an X id.
|
|
|
|
*
|
|
|
|
* Returns the Gdk object associated with the given X id.
|
|
|
|
*
|
|
|
|
* Return value: the associated Gdk object, which may be a #GdkPixmap,
|
|
|
|
* a #GdkWindow or a #GdkFont.
|
|
|
|
**/
|
2002-04-25 22:29:14 +00:00
|
|
|
gpointer
|
|
|
|
gdk_xid_table_lookup (XID xid)
|
|
|
|
{
|
2002-06-20 23:59:27 +00:00
|
|
|
return gdk_xid_table_lookup_for_display (gdk_display_get_default (), xid);
|
2002-04-25 22:29:14 +00:00
|
|
|
}
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
static guint
|
|
|
|
gdk_xid_hash (XID *xid)
|
|
|
|
{
|
|
|
|
return *xid;
|
|
|
|
}
|
|
|
|
|
2000-11-13 13:15:41 +00:00
|
|
|
static gboolean
|
|
|
|
gdk_xid_equal (XID *a,
|
|
|
|
XID *b)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2006-01-20 04:35:24 +00:00
|
|
|
return ((*a & ~XID_FONT_BIT) == (*b & ~XID_FONT_BIT));
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
2005-03-16 03:17:27 +00:00
|
|
|
|
|
|
|
#define __GDK_XID_C__
|
|
|
|
#include "gdkaliasdef.c"
|