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,
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurface *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);
|
2017-11-13 21:32:34 +00:00
|
|
|
|
2019-03-23 04:14:00 +00:00
|
|
|
display_x11->toplevels = g_list_prepend (display_x11->toplevels, 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;
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface;
|
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
|
|
|
|
2017-11-13 21:32:34 +00:00
|
|
|
if (!display_x11->xid_ht)
|
|
|
|
return;
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
surface = g_hash_table_lookup (display_x11->xid_ht, &xid);
|
2019-03-23 04:14:00 +00:00
|
|
|
if (surface)
|
2018-03-20 14:14:10 +00:00
|
|
|
display_x11->toplevels = g_list_remove (display_x11->toplevels, surface);
|
2017-11-13 21:32:34 +00:00
|
|
|
|
|
|
|
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
|
|
|
/**
|
2018-03-20 10:40:08 +00:00
|
|
|
* gdk_x11_surface_lookup_for_display:
|
2021-05-18 21:05:26 +00:00
|
|
|
* @display: (type GdkX11Display): the `GdkDisplay` corresponding to the
|
|
|
|
* window handle
|
2014-01-28 05:06:30 +00:00
|
|
|
* @window: an Xlib Window
|
2010-12-16 04:35:15 +00:00
|
|
|
*
|
2021-05-18 21:05:26 +00:00
|
|
|
* Looks up the `GdkSurface` that wraps the given native window handle.
|
2010-12-16 04:35:15 +00:00
|
|
|
*
|
2021-05-18 21:05:26 +00:00
|
|
|
* Returns: (transfer none) (type GdkX11Surface): the `GdkSurface` wrapper
|
|
|
|
* for the native window
|
2010-12-16 04:35:15 +00:00
|
|
|
*/
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurface *
|
|
|
|
gdk_x11_surface_lookup_for_display (GdkDisplay *display,
|
2010-12-16 04:35:15 +00:00
|
|
|
Window window)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2010-12-20 16:14:04 +00:00
|
|
|
GdkX11Display *display_x11;
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurface *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
|
|
|
}
|