From 45a6146ca6254a6caa58a8fdfeb6ba35a04202b5 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Fri, 15 Jun 2018 08:38:19 +0200 Subject: [PATCH] x11: Remove gdk_x11_surface_foreign_new_for_display() People who want to use foreign windows should use X directly. --- docs/reference/gdk/gdk4-sections.txt | 1 - gdk/x11/gdksurface-x11.c | 95 ---------------------------- gdk/x11/gdkx11surface.h | 3 - 3 files changed, 99 deletions(-) diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt index 4e80fc717a..21d1ed2934 100644 --- a/docs/reference/gdk/gdk4-sections.txt +++ b/docs/reference/gdk/gdk4-sections.txt @@ -849,7 +849,6 @@ gdk_x11_screen_lookup_visual gdk_x11_screen_supports_net_wm_hint gdk_x11_screen_get_number_of_desktops gdk_x11_screen_get_current_desktop -gdk_x11_surface_foreign_new_for_display gdk_x11_surface_lookup_for_display gdk_x11_surface_get_xid gdk_x11_surface_set_theme_variant diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c index 1b677a7786..96eba37274 100644 --- a/gdk/x11/gdksurface-x11.c +++ b/gdk/x11/gdksurface-x11.c @@ -987,101 +987,6 @@ _gdk_x11_display_create_surface_impl (GdkDisplay *display, gdk_surface_freeze_toplevel_updates (surface); } -/** - * gdk_x11_surface_foreign_new_for_display: - * @display: (type GdkX11Display): the #GdkDisplay where the window handle comes from. - * @window: an Xlib Window - * - * Wraps a native window in a #GdkSurface. The function will try to - * look up the window using gdk_x11_surface_lookup_for_display() first. - * If it does not find it there, it will create a new window. - * - * This may fail if the window has been destroyed. If the window - * was already known to GDK, a new reference to the existing - * #GdkSurface is returned. - * - * Returns: (transfer full): a #GdkSurface 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. - */ -GdkSurface * -gdk_x11_surface_foreign_new_for_display (GdkDisplay *display, - Window window) -{ - GdkX11Screen *screen; - GdkSurface *win; - GdkSurfaceImplX11 *impl; - GdkX11Display *display_x11; - XWindowAttributes attrs; - Window root, parent; - Window *children = NULL; - guint nchildren; - gboolean result; - - g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL); - - display_x11 = GDK_X11_DISPLAY (display); - - if ((win = gdk_x11_surface_lookup_for_display (display, window)) != NULL) - return g_object_ref (win); - - 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_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); - if (screen == NULL) - return NULL; - - win = _gdk_display_create_surface (display); - win->impl = g_object_new (GDK_TYPE_SURFACE_IMPL_X11, NULL); - win->impl_surface = win; - - impl = GDK_SURFACE_IMPL_X11 (win->impl); - impl->wrapper = win; - impl->surface_scale = GDK_X11_SCREEN (screen)->surface_scale; - - /* Always treat foreigns as toplevels */ - win->parent = NULL; - - impl->xid = window; - - win->x = attrs.x / impl->surface_scale; - win->y = attrs.y / impl->surface_scale; - impl->unscaled_width = attrs.width; - impl->unscaled_height = attrs.height; - win->width = attrs.width / impl->surface_scale; - win->height = attrs.height / impl->surface_scale; - win->surface_type = GDK_SURFACE_FOREIGN; - win->destroyed = FALSE; - - if (attrs.map_state == IsUnmapped) - win->state = GDK_SURFACE_STATE_WITHDRAWN; - else - win->state = 0; - win->viewable = TRUE; - - g_object_ref (win); - _gdk_x11_display_add_window (display, &GDK_SURFACE_XID (win), win); - - /* Update the clip region, etc */ - _gdk_surface_update_size (win); - - return win; -} - static void gdk_toplevel_x11_free_contents (GdkDisplay *display, GdkToplevelX11 *toplevel) diff --git a/gdk/x11/gdkx11surface.h b/gdk/x11/gdkx11surface.h index 279efed8f0..bb23dbee71 100644 --- a/gdk/x11/gdkx11surface.h +++ b/gdk/x11/gdkx11surface.h @@ -101,9 +101,6 @@ void gdk_x11_surface_set_frame_sync_enabled (GdkSurface *surface, GDK_AVAILABLE_IN_ALL guint32 gdk_x11_get_server_time (GdkSurface *surface); -GDK_AVAILABLE_IN_ALL -GdkSurface *gdk_x11_surface_foreign_new_for_display (GdkDisplay *display, - Window window); GDK_AVAILABLE_IN_ALL GdkSurface *gdk_x11_surface_lookup_for_display (GdkDisplay *display, Window window); -- 2.30.2