[gtk+] x11: Add API to query root window and screen from GdkDisplay



commit f33c20920b91a681957585211b4758cf12abedbf
Author: Benjamin Otte <otte redhat com>
Date:   Wed Nov 1 22:56:46 2017 +0100

    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 29ee2f9..324dcfc 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 752d2ab..6a9ba12 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 93d9aa6..a72b9db 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 adb47b1..03a1653 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,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]