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
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
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/.
|
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
2010-10-15 02:05:51 +00:00
|
|
|
|
1999-11-08 20:14:59 +00:00
|
|
|
#include "gdkprivate-x11.h"
|
2002-04-25 22:29:14 +00:00
|
|
|
#include "gdkdisplay-x11.h"
|
2010-10-15 02:05:51 +00:00
|
|
|
|
1997-12-18 02:17:14 +00:00
|
|
|
#include <stdio.h>
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2010-12-15 19:49:23 +00:00
|
|
|
static guint
|
|
|
|
gdk_xid_hash (XID *xid)
|
|
|
|
{
|
|
|
|
return *xid;
|
|
|
|
}
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2010-12-15 19:49:23 +00:00
|
|
|
static gboolean
|
|
|
|
gdk_xid_equal (XID *a, XID *b)
|
|
|
|
{
|
|
|
|
return (*a == *b);
|
|
|
|
}
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
void
|
2010-12-16 04:35:15 +00:00
|
|
|
_gdk_x11_display_add_window (GdkDisplay *display,
|
|
|
|
XID *xid,
|
|
|
|
GdkWindow *data)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2010-12-20 16:14:04 +00:00
|
|
|
GdkX11Display *display_x11;
|
2009-05-05 23:29:05 +00:00
|
|
|
|
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));
|
2009-05-05 23:29:05 +00:00
|
|
|
|
2010-12-20 18:20:10 +00:00
|
|
|
display_x11 = GDK_X11_DISPLAY (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,
|
2010-12-15 19:49:23 +00:00
|
|
|
(GEqualFunc) gdk_xid_equal);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2009-05-05 23:29:05 +00:00
|
|
|
if (g_hash_table_lookup (display_x11->xid_ht, xid))
|
|
|
|
g_warning ("XID collision, trouble ahead");
|
|
|
|
|
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
|
2010-12-16 04:35:15 +00:00
|
|
|
_gdk_x11_display_remove_window (GdkDisplay *display,
|
|
|
|
XID xid)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2010-12-20 16:14:04 +00:00
|
|
|
GdkX11Display *display_x11;
|
2009-05-05 23:29:05 +00:00
|
|
|
|
2002-04-25 22:29:14 +00:00
|
|
|
g_return_if_fail (GDK_IS_DISPLAY (display));
|
2009-05-05 23:29:05 +00:00
|
|
|
|
2010-12-20 18:20:10 +00:00
|
|
|
display_x11 = GDK_X11_DISPLAY (display);
|
2009-05-05 23:29:05 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-12-16 04:35:15 +00:00
|
|
|
/**
|
|
|
|
* gdk_x11_window_lookup_for_display:
|
2011-07-28 11:27:23 +00:00
|
|
|
* @display: (type GdkX11Window): the #GdkDisplay corresponding to the
|
|
|
|
* window handle
|
2010-12-16 04:35:15 +00:00
|
|
|
* @window: an XLib <type>Window</type>
|
|
|
|
*
|
|
|
|
* Looks up the #GdkWindow that wraps the given native window handle.
|
|
|
|
*
|
|
|
|
* Return value: (transfer none): the #GdkWindow wrapper for the native
|
|
|
|
* window, or %NULL if there is none.
|
|
|
|
*
|
2010-12-17 06:48:12 +00:00
|
|
|
* Since: 2.24
|
2010-12-16 04:35:15 +00:00
|
|
|
*/
|
|
|
|
GdkWindow *
|
|
|
|
gdk_x11_window_lookup_for_display (GdkDisplay *display,
|
|
|
|
Window window)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2010-12-20 16:14:04 +00:00
|
|
|
GdkX11Display *display_x11;
|
2010-12-16 04:35:15 +00:00
|
|
|
GdkWindow *data = NULL;
|
2010-12-15 19:49:23 +00:00
|
|
|
|
2002-04-25 22:29:14 +00:00
|
|
|
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
|
2010-12-15 19:49:23 +00:00
|
|
|
|
2010-12-20 18:20:10 +00:00
|
|
|
display_x11 = GDK_X11_DISPLAY (display);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-04-25 22:29:14 +00:00
|
|
|
if (display_x11->xid_ht)
|
2010-12-16 04:35:15 +00:00
|
|
|
data = g_hash_table_lookup (display_x11->xid_ht, &window);
|
2002-10-22 22:11:22 +00:00
|
|
|
|
2010-12-15 19:49:23 +00:00
|
|
|
return data;
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|