From f33c20920b91a681957585211b4758cf12abedbf Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 1 Nov 2017 22:56:46 +0100 Subject: [PATCH] x11: Add API to query root window and screen from GdkDisplay --- docs/reference/gdk/gdk4-sections.txt | 2 ++ gdk/x11/gdkdisplay-x11.c | 37 ++++++++++++++++++++++++++++ gdk/x11/gdkx11display.h | 6 ++++- gtk/gtkmountoperation-x11.c | 4 +-- 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt index 29ee2f9342..324dcfcfe1 100644 --- a/docs/reference/gdk/gdk4-sections.txt +++ b/docs/reference/gdk/gdk4-sections.txt @@ -898,6 +898,8 @@ gdk_x11_display_broadcast_startup_message gdk_x11_display_get_startup_notification_id gdk_x11_display_set_startup_notification_id gdk_x11_display_get_xdisplay +gdk_x11_display_get_xscreen +gdk_x11_display_get_xrootwindow gdk_x11_display_grab gdk_x11_display_ungrab gdk_x11_display_error_trap_push diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index 752d2abfd0..6a9ba12238 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -2179,9 +2179,46 @@ Display * gdk_x11_display_get_xdisplay (GdkDisplay *display) { g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL); + return GDK_X11_DISPLAY (display)->xdisplay; } +/** + * gdk_x11_display_get_xscreen: + * @display: (type GdkX11Display): a #GdkDisplay + * + * Returns the X Screen used by #GdkDisplay. + * + * Returns: (transfer none): an X Screen + * + * Since: 3.94 + */ +Screen * +gdk_x11_display_get_xscreen (GdkDisplay *display) +{ + g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL); + + return GDK_X11_SCREEN (GDK_X11_DISPLAY (display)->screen)->xscreen; +} + +/** + * gdk_x11_display_get_xrootwindow: + * @display: (type GdkX11Display): a #GdkDisplay + * + * Returns the root X window used by #GdkDisplay. + * + * Returns: (transfer none): an X Window + * + * Since: 3.94 + */ +Window +gdk_x11_display_get_xrootwindow (GdkDisplay *display) +{ + g_return_val_if_fail (GDK_IS_DISPLAY (display), None); + + return GDK_SCREEN_XROOTWIN (GDK_X11_DISPLAY (display)->screen); +} + static void gdk_x11_display_make_default (GdkDisplay *display) { diff --git a/gdk/x11/gdkx11display.h b/gdk/x11/gdkx11display.h index 93d9aa61fb..a72b9db47b 100644 --- a/gdk/x11/gdkx11display.h +++ b/gdk/x11/gdkx11display.h @@ -57,7 +57,11 @@ GDK_AVAILABLE_IN_3_94 GdkDisplay * gdk_x11_display_open (const char *display_name); GDK_AVAILABLE_IN_ALL -Display *gdk_x11_display_get_xdisplay (GdkDisplay *display); +Display * gdk_x11_display_get_xdisplay (GdkDisplay *display); +GDK_AVAILABLE_IN_3_94 +Screen * gdk_x11_display_get_xscreen (GdkDisplay *display); +GDK_AVAILABLE_IN_3_94 +Window gdk_x11_display_get_xrootwindow (GdkDisplay *display); #define GDK_DISPLAY_XDISPLAY(display) (gdk_x11_display_get_xdisplay (display)) diff --git a/gtk/gtkmountoperation-x11.c b/gtk/gtkmountoperation-x11.c index adb47b1659..03a1653904 100644 --- a/gtk/gtkmountoperation-x11.c +++ b/gtk/gtkmountoperation-x11.c @@ -532,8 +532,8 @@ _gtk_mount_operation_lookup_context_get (GdkDisplay *display) mapping = NULL; mapping_length = 0; - get_window_list (GDK_DISPLAY_XDISPLAY (context->display), - GDK_ROOT_WINDOW(), + get_window_list (gdk_x11_display_get_xdisplay (context->display), + gdk_x11_display_get_xrootwindow (context->display), gdk_x11_get_xatom_by_name_for_display (context->display, "_NET_CLIENT_LIST"), &mapping,