Commit 2d7583c0 authored by Matthias Clasen's avatar Matthias Clasen

Make gdk_window_{lookup,foreign_new}_for_display backend specific

At the same time, make GDK_IS_DISPLAY_X11 available in gdkx.h, and
add some exemplaric ifdefs to GTK+ code.
parent 39a71b88
......@@ -954,12 +954,10 @@ GDK_SCREEN_XSCREEN
GDK_CURSOR_XCURSOR
GDK_CURSOR_XDISPLAY
gdkx_visual_get
gdk_window_foreign_new
gdk_window_foreign_new_for_display
gdk_x11_window_foreign_new_for_display
gdk_xid_table_lookup
gdk_xid_table_lookup_for_display
gdk_window_lookup
gdk_window_lookup_for_display
gdk_x11_window_lookup_for_display
gdk_x11_lookup_xdisplay
gdk_x11_get_server_time
gdk_net_wm_supports
......
......@@ -138,7 +138,7 @@ take_window_shot (Window child,
else
xid = child;
window = gdk_window_foreign_new (xid);
window = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (), xid);
width = gdk_window_get_width (window);
height = gdk_window_get_height (window);
......
......@@ -403,8 +403,6 @@ gdk_window_end_paint
gdk_window_ensure_native
gdk_window_flush
gdk_window_focus
gdk_window_foreign_new
gdk_window_foreign_new_for_display
gdk_window_freeze_toplevel_updates_libgtk_only
gdk_window_freeze_updates
gdk_window_fullscreen
......@@ -463,8 +461,6 @@ gdk_window_is_input_only
gdk_window_is_shaped
gdk_window_is_viewable
gdk_window_is_visible
gdk_window_lookup
gdk_window_lookup_for_display
gdk_window_lower
gdk_window_maximize
gdk_window_merge_child_input_shapes
......@@ -569,6 +565,8 @@ gdk_x11_screen_supports_net_wm_hint
gdk_x11_set_sm_client_id
gdk_x11_ungrab_server
gdk_x11_visual_get_xvisual
gdk_x11_window_foreign_new_for_display
gdk_x11_window_lookup_for_display
gdk_x11_window_get_xid
gdk_x11_window_move_to_current_desktop
gdk_x11_window_set_user_time
......
......@@ -5058,25 +5058,6 @@ gdk_get_default_root_window (void)
return gdk_screen_get_root_window (gdk_screen_get_default ());
}
/**
* gdk_window_foreign_new:
* @anid: a native window handle.
*
* Wraps a native window for the default display in a #GdkWindow.
* This may fail if the window has been destroyed.
*
* For example in the X backend, a native window handle is an Xlib
* <type>XID</type>.
*
* Return value: (transfer full): the newly-created #GdkWindow wrapper
* for the native window, or %NULL if the window has been destroyed.
**/
GdkWindow *
gdk_window_foreign_new (GdkNativeWindow anid)
{
return gdk_window_foreign_new_for_display (gdk_display_get_default (), anid);
}
static void
get_all_native_children (GdkWindow *window,
GList **native)
......@@ -10745,21 +10726,3 @@ gdk_drag_begin_for_device (GdkWindow *window,
{
return GDK_WINDOW_IMPL_GET_CLASS (window->impl)->drag_begin (window, device, targets);
}
/**
* gdk_window_lookup:
* @anid: a native window handle
*
* Looks up the #GdkWindow that wraps the given native window handle.
*
* For example in the X backend, a native window handle is an Xlib
* <type>XID</type>.
*
* Return value: (transfer none): the #GdkWindow wrapper for the native
* window, or %NULL if there is none.
**/
GdkWindow *
gdk_window_lookup (GdkNativeWindow anid)
{
return gdk_window_lookup_for_display (gdk_display_get_default (), anid);
}
......@@ -642,18 +642,7 @@ GdkWindowState gdk_window_get_state (GdkWindow *window);
* window gravity on all children.
*/
gboolean gdk_window_set_static_gravities (GdkWindow *window,
gboolean use_static);
/* Functions to create/lookup windows from their native equivalents */
#ifndef GDK_MULTIHEAD_SAFE
GdkWindow* gdk_window_foreign_new (GdkNativeWindow anid);
GdkWindow* gdk_window_lookup (GdkNativeWindow anid);
#endif
GdkWindow *gdk_window_foreign_new_for_display (GdkDisplay *display,
GdkNativeWindow anid);
GdkWindow* gdk_window_lookup_for_display (GdkDisplay *display,
GdkNativeWindow anid);
gboolean use_static);
/* GdkWindow */
......
......@@ -289,10 +289,10 @@ gdk_device_core_query_state (GdkDevice *device,
}
if (root_window)
*root_window = gdk_window_lookup_for_display (display, xroot_window);
*root_window = gdk_x11_window_lookup_for_display (display, xroot_window);
if (child_window)
*child_window = gdk_window_lookup_for_display (display, xchild_window);
*child_window = gdk_x11_window_lookup_for_display (display, xchild_window);
if (root_x)
*root_x = xroot_x;
......@@ -529,7 +529,7 @@ gdk_device_core_window_at_position (GdkDevice *device,
break;
if (get_toplevel && last != root &&
(window = gdk_window_lookup_for_display (display, last)) != NULL &&
(window = gdk_x11_window_lookup_for_display (display, last)) != NULL &&
window->window_type != GDK_WINDOW_FOREIGN)
{
xwindow = last;
......@@ -539,7 +539,7 @@ gdk_device_core_window_at_position (GdkDevice *device,
gdk_x11_display_ungrab (display);
window = gdk_window_lookup_for_display (display, last);
window = gdk_x11_window_lookup_for_display (display, last);
if (win_x)
*win_x = (window) ? xwin_x : -1;
......
......@@ -357,10 +357,10 @@ gdk_device_xi2_query_state (GdkDevice *device,
}
if (root_window)
*root_window = gdk_window_lookup_for_display (display, xroot_window);
*root_window = gdk_x11_window_lookup_for_display (display, xroot_window);
if (child_window)
*child_window = gdk_window_lookup_for_display (display, xchild_window);
*child_window = gdk_x11_window_lookup_for_display (display, xchild_window);
if (root_x)
*root_x = (gint) xroot_x;
......@@ -590,7 +590,7 @@ gdk_device_xi2_window_at_position (GdkDevice *device,
break;
if (get_toplevel && last != root &&
(window = gdk_window_lookup_for_display (display, last)) != NULL &&
(window = gdk_x11_window_lookup_for_display (display, last)) != NULL &&
GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN)
{
xwindow = last;
......@@ -600,7 +600,7 @@ gdk_device_xi2_window_at_position (GdkDevice *device,
gdk_x11_display_ungrab (display);
window = gdk_window_lookup_for_display (display, last);
window = gdk_x11_window_lookup_for_display (display, last);
if (win_x)
*win_x = (window) ? (gint) xwin_x : -1;
......
......@@ -384,7 +384,7 @@ get_event_window (GdkEventTranslator *translator,
device_manager = GDK_DEVICE_MANAGER (translator);
display = gdk_device_manager_get_display (device_manager);
window = gdk_window_lookup_for_display (display, xevent->xany.window);
window = gdk_x11_window_lookup_for_display (display, xevent->xany.window);
/* Apply keyboard grabs to non-native windows */
if (xevent->type == KeyPress || xevent->type == KeyRelease)
......@@ -680,7 +680,7 @@ gdk_device_manager_core_translate_event (GdkEventTranslator *translator,
* lookup the corresponding GdkWindow.
*/
if (xevent->xcrossing.subwindow != None)
event->crossing.subwindow = gdk_window_lookup_for_display (display, xevent->xcrossing.subwindow);
event->crossing.subwindow = gdk_x11_window_lookup_for_display (display, xevent->xcrossing.subwindow);
else
event->crossing.subwindow = NULL;
......@@ -724,7 +724,7 @@ gdk_device_manager_core_translate_event (GdkEventTranslator *translator,
* lookup the corresponding GdkWindow.
*/
if (xevent->xcrossing.subwindow != None)
event->crossing.subwindow = gdk_window_lookup_for_display (display, xevent->xcrossing.subwindow);
event->crossing.subwindow = gdk_x11_window_lookup_for_display (display, xevent->xcrossing.subwindow);
else
event->crossing.subwindow = NULL;
......
......@@ -104,7 +104,7 @@ window_input_info_filter (GdkXEvent *xevent,
xev = (XEvent *) xevent;
display = gdk_device_manager_get_display (device_manager);
window = gdk_window_lookup_for_display (display, xev->xany.window);
window = gdk_x11_window_lookup_for_display (display, xev->xany.window);
if (window && xev->type == ConfigureNotify)
gdk_device_xi_update_window_info (window);
......@@ -421,7 +421,7 @@ gdk_device_manager_xi_translate_event (GdkEventTranslator *translator,
if (!device)
return FALSE;
window = gdk_window_lookup_for_display (display, xevent->xany.window);
window = gdk_x11_window_lookup_for_display (display, xevent->xany.window);
if (!window)
return FALSE;
......
......@@ -894,7 +894,7 @@ get_event_window (GdkEventTranslator *translator,
{
XIDeviceEvent *xev = (XIDeviceEvent *) ev;
window = gdk_window_lookup_for_display (display, xev->event);
window = gdk_x11_window_lookup_for_display (display, xev->event);
/* Apply keyboard grabs to non-native windows */
if (ev->evtype == XI_KeyPress || ev->evtype == XI_KeyRelease)
......@@ -926,7 +926,7 @@ get_event_window (GdkEventTranslator *translator,
{
XIEnterEvent *xev = (XIEnterEvent *) ev;
window = gdk_window_lookup_for_display (display, xev->event);
window = gdk_x11_window_lookup_for_display (display, xev->event);
}
break;
}
......@@ -1188,7 +1188,7 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator,
event->crossing.focus = xev->focus;
event->crossing.window = window;
event->crossing.subwindow = gdk_window_lookup_for_display (display, xev->child);
event->crossing.subwindow = gdk_x11_window_lookup_for_display (display, xev->child);
device = g_hash_table_lookup (device_manager->id_table,
GINT_TO_POINTER (xev->deviceid));
......
......@@ -368,7 +368,7 @@ get_event_window (GdkEventTranslator *translator,
xwindow = xevent->xany.window;
}
return gdk_window_lookup_for_display (display, xwindow);
return gdk_x11_window_lookup_for_display (display, xwindow);
}
static gboolean
......
......@@ -41,7 +41,6 @@ typedef struct _GdkDisplayX11Class GdkDisplayX11Class;
#define GDK_TYPE_DISPLAY_X11 (_gdk_display_x11_get_type())
#define GDK_DISPLAY_X11(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DISPLAY_X11, GdkDisplayX11))
#define GDK_DISPLAY_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DISPLAY_X11, GdkDisplayX11Class))
#define GDK_IS_DISPLAY_X11(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DISPLAY_X11))
#define GDK_IS_DISPLAY_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DISPLAY_X11))
#define GDK_DISPLAY_X11_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DISPLAY_X11, GdkDisplayX11Class))
......
......@@ -988,8 +988,8 @@ motif_find_drag_window (GdkDisplay *display,
*/
if (display_x11->motif_drag_window)
{
display_x11->motif_drag_gdk_window =
gdk_window_foreign_new_for_display (display, display_x11->motif_drag_window);
display_x11->motif_drag_gdk_window =
gdk_x11_window_foreign_new_for_display (display, display_x11->motif_drag_window);
gdk_window_add_filter (display_x11->motif_drag_gdk_window,
motif_drag_window_filter,
NULL);
......@@ -1668,12 +1668,12 @@ motif_drag_context_new (GdkWindow *dest_window,
context->protocol = GDK_DRAG_PROTO_MOTIF;
context->is_source = FALSE;
context->source_window = gdk_window_lookup_for_display (display, source_window);
context->source_window = gdk_x11_window_lookup_for_display (display, source_window);
if (context->source_window)
g_object_ref (context->source_window);
else
{
context->source_window = gdk_window_foreign_new_for_display (display, source_window);
context->source_window = gdk_x11_window_foreign_new_for_display (display, source_window);
if (!context->source_window)
{
g_object_unref (context_x11);
......@@ -2843,12 +2843,12 @@ xdnd_enter_filter (GdkXEvent *xev,
device_manager = gdk_display_get_device_manager (display);
gdk_drag_context_set_device (context, gdk_device_manager_get_client_pointer (device_manager));
context->source_window = gdk_window_lookup_for_display (display, source_window);
context->source_window = gdk_x11_window_lookup_for_display (display, source_window);
if (context->source_window)
g_object_ref (context->source_window);
else
{
context->source_window = gdk_window_foreign_new_for_display (display, source_window);
context->source_window = gdk_x11_window_foreign_new_for_display (display, source_window);
if (!context->source_window)
{
g_object_unref (context);
......@@ -3158,7 +3158,7 @@ _gdk_x11_display_get_drag_protocol (GdkDisplay *display,
base_precache_atoms (display);
/* Check for a local drag */
window = gdk_window_lookup_for_display (display, xid);
window = gdk_x11_window_lookup_for_display (display, xid);
if (window && gdk_window_get_window_type (window) != GDK_WINDOW_FOREIGN)
{
if (g_object_get_data (G_OBJECT (window), "gdk-dnd-registered") != NULL)
......@@ -3273,11 +3273,11 @@ gdk_drag_context_x11_find_window (GdkDragContext *context,
if (recipient != None)
{
dest_window = gdk_window_lookup_for_display (display, recipient);
dest_window = gdk_x11_window_lookup_for_display (display, recipient);
if (dest_window)
g_object_ref (dest_window);
else
dest_window = gdk_window_foreign_new_for_display (display, recipient);
dest_window = gdk_x11_window_foreign_new_for_display (display, recipient);
}
else
dest_window = NULL;
......
......@@ -101,7 +101,7 @@ gdk_event_source_get_filter_window (GdkEventSource *event_source,
{
GdkWindow *window;
window = gdk_window_lookup_for_display (event_source->display,
window = gdk_x11_window_lookup_for_display (event_source->display,
xevent->xany.window);
if (window && !GDK_IS_WINDOW (window))
......
......@@ -1023,8 +1023,8 @@ gdk_screen_x11_get_active_window (GdkScreen *screen)
if (window != None)
{
ret = gdk_window_foreign_new_for_display (screen_x11->display,
*(GdkNativeWindow *) data);
ret = gdk_x11_window_foreign_new_for_display (screen_x11->display,
*(Window *) data);
}
}
}
......@@ -1071,8 +1071,8 @@ gdk_screen_x11_get_window_stack (GdkScreen *screen)
for (i = 0; i < nitems_return; i++)
{
win = gdk_window_foreign_new_for_display (screen_x11->display,
(GdkNativeWindow)stack[i]);
win = gdk_x11_window_foreign_new_for_display (screen_x11->display,
(Window)stack[i]);
if (win != NULL)
ret = g_list_append (ret, win);
......@@ -1507,7 +1507,7 @@ gdk_xsettings_watch_cb (Window window,
GdkWindow *gdkwin;
GdkScreen *screen = cb_data;
gdkwin = gdk_window_lookup_for_display (gdk_screen_get_display (screen), window);
gdkwin = gdk_x11_window_lookup_for_display (gdk_screen_get_display (screen), window);
if (is_start)
{
......@@ -1515,7 +1515,7 @@ gdk_xsettings_watch_cb (Window window,
g_object_ref (gdkwin);
else
{
gdkwin = gdk_window_foreign_new_for_display (gdk_screen_get_display (screen), window);
gdkwin = gdk_x11_window_foreign_new_for_display (gdk_screen_get_display (screen), window);
/* gdk_window_foreign_new_for_display() can fail and return NULL if the
* window has already been destroyed.
......
......@@ -221,7 +221,7 @@ gdk_selection_owner_get_for_display (GdkDisplay *display,
if (xwindow == None)
return NULL;
return gdk_window_lookup_for_display (display, xwindow);
return gdk_x11_window_lookup_for_display (display, xwindow);
}
void
......
......@@ -848,30 +848,28 @@ x_event_mask_to_gdk_event_mask (long mask)
}
/**
* gdk_window_foreign_new_for_display:
* gdk_x11_window_foreign_new_for_display:
* @display: the #GdkDisplay where the window handle comes from.
* @anid: a native window handle.
*
* @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
* was already known to GDK, a new reference to the existing
* #GdkWindow is returned.
*
* For example in the X backend, a native window handle is an Xlib
* <type>XID</type>.
*
* Return value: (transfer full): 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
**/
* Since: 3.0
*/
GdkWindow *
gdk_window_foreign_new_for_display (GdkDisplay *display,
GdkNativeWindow anid)
gdk_x11_window_foreign_new_for_display (GdkDisplay *display,
Window window)
{
GdkScreen *screen;
GdkWindow *window;
GdkWindow *win;
GdkWindowImplX11 *impl;
GdkDisplayX11 *display_x11;
XWindowAttributes attrs;
......@@ -884,90 +882,88 @@ 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);
if (gdk_error_trap_pop () || !result)
gdk_x11_display_error_trap_push (display);
result = XGetWindowAttributes (display_x11->xdisplay, window, &attrs);
if (gdk_x11_display_error_trap_pop (display) || !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);
if (gdk_error_trap_pop () || !result)
/* FIXME: This is pretty expensive.
* Maybe the caller should supply the parent
*/
gdk_x11_display_error_trap_push (display);
result = XQueryTree (display_x11->xdisplay, window, &root, &parent, &children, &nchildren);
if (gdk_x11_display_error_trap_pop (display) || !result)
return NULL;
if (children)
XFree (children);
screen = _gdk_x11_display_screen_for_xrootwin (display, root);
window = g_object_new (GDK_TYPE_WINDOW, NULL);
win = g_object_new (GDK_TYPE_WINDOW, NULL);
win->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_X11, NULL);
win->impl_window = win;
win->visual = gdk_x11_screen_lookup_visual (screen,
XVisualIDFromVisual (attrs.visual));
window->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_X11, NULL);
window->impl_window = window;
window->visual = gdk_x11_screen_lookup_visual (screen,
XVisualIDFromVisual (attrs.visual));
impl = GDK_WINDOW_IMPL_X11 (win->impl);
impl->wrapper = win;
impl = GDK_WINDOW_IMPL_X11 (window->impl);
impl->wrapper = window;
window->parent = gdk_xid_table_lookup_for_display (display, parent);
if (!window->parent || GDK_WINDOW_TYPE (window->parent) == GDK_WINDOW_FOREIGN)
window->parent = gdk_screen_get_root_window (screen);
window->parent->children = g_list_prepend (window->parent->children, window);
win->parent = gdk_xid_table_lookup_for_display (display, parent);
if (!win->parent || GDK_WINDOW_TYPE (win->parent) == GDK_WINDOW_FOREIGN)
win->parent = gdk_screen_get_root_window (screen);
impl->xid = anid;
win->parent->children = g_list_prepend (win->parent->children, win);
window->x = attrs.x;
window->y = attrs.y;
window->width = attrs.width;
window->height = attrs.height;
window->window_type = GDK_WINDOW_FOREIGN;
window->destroyed = FALSE;
impl->xid = window;
window->event_mask = x_event_mask_to_gdk_event_mask (attrs.your_event_mask);
win->x = attrs.x;
win->y = attrs.y;
win->width = attrs.width;
win->height = attrs.height;
win->window_type = GDK_WINDOW_FOREIGN;
win->destroyed = FALSE;
win->event_mask = x_event_mask_to_gdk_event_mask (attrs.your_event_mask);
if (attrs.map_state == IsUnmapped)
window->state = GDK_WINDOW_STATE_WITHDRAWN;
win->state = GDK_WINDOW_STATE_WITHDRAWN;
else
window->state = 0;
window->viewable = TRUE;
win->state = 0;
win->viewable = TRUE;
window->depth = attrs.depth;
g_object_ref (window);
_gdk_xid_table_insert (display, &GDK_WINDOW_XID (window), window);
win->depth = attrs.depth;
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;
}
/**
* gdk_window_lookup_for_display:
* gdk_x11_window_lookup_for_display:
* @display: the #GdkDisplay corresponding to the window handle
* @anid: a native window handle.
* @window: an XLib <type>Window</type>
*
* Looks up the #GdkWindow that wraps the given native window handle.
*
* For example in the X backend, a native window handle is an Xlib
* <type>XID</type>.
*
* Return value: (transfer none): the #GdkWindow wrapper for the native
* window, or %NULL if there is none.
*
* Since: 2.2
**/
* Since: 3.0
*/
GdkWindow *
gdk_window_lookup_for_display (GdkDisplay *display, GdkNativeWindow anid)
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);
}
static void
......@@ -1008,11 +1004,11 @@ gdk_x11_window_destroy (GdkWindow *window,
{
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
GdkToplevelX11 *toplevel;
g_return_if_fail (GDK_IS_WINDOW (window));
_gdk_selection_window_destroyed (window);
toplevel = _gdk_x11_window_get_toplevel (window);
if (toplevel)
gdk_toplevel_x11_free_contents (GDK_WINDOW_DISPLAY (window), toplevel);
......@@ -1021,13 +1017,11 @@ gdk_x11_window_destroy (GdkWindow *window,
{
cairo_surface_finish (impl->cairo_surface);
cairo_surface_set_user_data (impl->cairo_surface, &gdk_x11_cairo_key,
NULL, NULL);
NULL, NULL);
}
if (!recursing && !foreign_destroy)
{
XDestroyWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
}
XDestroyWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
}
static cairo_surface_t *
......@@ -1049,28 +1043,28 @@ gdk_x11_window_destroy_foreign (GdkWindow *window)
* it a delete event, as if we were a WM
*/
XClientMessageEvent xclient;
gdk_error_trap_push ();
GdkDisplay *display;
display = GDK_WINDOW_DISPLAY (window);
gdk_x11_display_error_trap_push (display);
gdk_window_hide (window);
gdk_window_reparent (window, NULL, 0, 0);
memset (&xclient, 0, sizeof (xclient));
xclient.type = ClientMessage;
xclient.window = GDK_WINDOW_XID (window);
xclient.message_type = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
"WM_PROTOCOLS");
xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "WM_PROTOCOLS");
xclient.format = 32;
xclient.data.l[0] = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
"WM_DELETE_WINDOW");
xclient.data.l[0] = gdk_x11_get_xatom_by_name_for_display (display, "WM_DELETE_WINDOW");
xclient.data.l[1] = CurrentTime;
xclient.data.l[2] = 0;
xclient.data.l[3] = 0;
xclient.data.l[4] = 0;
XSendEvent (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
False, 0, (XEvent *)&xclient);
gdk_error_trap_pop_ignored ();
GDK_WINDOW_XID (window),
False, 0, (XEvent *)&xclient);
gdk_x11_display_error_trap_pop_ignored (display);
}
static GdkWindow *
......
......@@ -95,6 +95,7 @@ gint gdk_x11_get_default_screen (void);
*/
#define GDK_CURSOR_XCURSOR(cursor) (gdk_x11_cursor_get_xcursor (cursor))
#define GDK_IS_DISPLAY_X11(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), g_type_from_name ("GdkDisplayX11")))
#ifdef GDK_COMPILATION
......@@ -250,6 +251,11 @@ void gdk_x11_register_standard_event_type (GdkDisplay *display,
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__ */
......@@ -316,7 +316,7 @@ _gtk_plug_windowing_filter_func (GdkXEvent *gdk_xevent,
GTK_NOTE (PLUGSOCKET, g_message ("GtkPlug: start of embedding"));
priv->socket_window = gdk_window_lookup_for_display (display, xre->parent);
priv->socket_window = gdk_x11_window_lookup_for_display (display, xre->parent);
if (priv->socket_window)
{
gpointer user_data = NULL;
......@@ -333,7 +333,7 @@ _gtk_plug_windowing_filter_func (GdkXEvent *gdk_xevent,
}
else
{
priv->socket_window = gdk_window_foreign_new_for_display (display, xre->parent);
priv->socket_window = gdk_x11_window_foreign_new_for_display (display, xre->parent);
if (!priv->socket_window) /* Already gone */
break; /* FIXME: shouldn't this unref the plug? i.e. "goto done;" instead */
}
......
......@@ -37,6 +37,10 @@
#include "gtkwidgetprivate.h"
#include "gtkwindowprivate.h"
#ifdef GDK_WINDOWING_X11
#include "x11/gdkx.h"
#endif
/**
* SECTION:gtkplug
* @Short_description: Toplevel for embedding into other processes
......@@ -513,7 +517,13 @@ gtk_plug_construct_for_display (GtkPlug *plug,
{
gpointer user_data = NULL;
priv->socket_window = gdk_window_lookup_for_display (display, socket_id);
#ifdef GDK_WINDOWING_X11
if (GDK_IS_DISPLAY_X11 (display))
priv->socket_window = gdk_x11_window_lookup_for_display (display, socket_id);
else
#endif
priv->socket_window = NULL;
if (priv->socket_window)
{
gdk_window_get_user_data (priv->socket_window, &user_data);
......@@ -532,7 +542,10 @@ gtk_plug_construct_for_display (GtkPlug *plug,
g_object_ref (priv->socket_window);
}
else
priv->socket_window = gdk_window_foreign_new_for_display (display, socket_id);
#ifdef GDK_WINDOWING_X11
if (GDK_IS_DISPLAY_X11 (display))
priv->socket_window = gdk_x11_window_foreign_new_for_display (display, socket_id);
#endif
if (priv->socket_window) {
g_signal_emit (plug, plug_signals[EMBEDDED], 0);
......
......@@ -2266,20 +2266,20 @@ _gtk_selection_request (GtkWidget *widget,
info = g_slice_new (GtkIncrInfo);
g_object_ref (widget);
info->selection = event->selection;
info->num_incrs = 0;
/* Create GdkWindow structure for the requestor */
info->requestor = gdk_window_lookup_for_display (display,
event->requestor);
if (!info->requestor)
info->requestor = gdk_window_foreign_new_for_display (display,