[gnome-shell] shell-util: Add API to check for X11 extensions



commit 7220f6d25b6b440301e02cb62872156ebab17aa7
Author: Jonas Ådahl <jadahl gmail com>
Date:   Tue Oct 1 11:55:33 2019 +0200

    shell-util: Add API to check for X11 extensions
    
    Will be used to disable animations when running inside Xvnc. This was
    done in gsd-xsettings before.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/757

 src/shell-util.c | 26 ++++++++++++++++++++++++++
 src/shell-util.h |  3 +++
 2 files changed, 29 insertions(+)
---
diff --git a/src/shell-util.c b/src/shell-util.c
index f344ec50bb..918dcdf0b7 100644
--- a/src/shell-util.c
+++ b/src/shell-util.c
@@ -20,6 +20,8 @@
 #include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
+#include <meta/display.h>
+#include <meta/meta-x11-display.h>
 
 #include <locale.h>
 #ifdef HAVE__NL_TIME_FIRST_WEEKDAY
@@ -639,3 +641,27 @@ shell_util_sd_notify (void)
    * our environment. */
   sd_notify (1, "READY=1");
 }
+
+/**
+ * shell_util_has_x11_display_extension:
+ * @display: A #MetaDisplay
+ * @extension: An X11 extension
+ *
+ * If the corresponding X11 display provides the passed extension, return %TRUE,
+ * otherwise %FALSE. If there is no X11 display, %FALSE is passed.
+ */
+gboolean
+shell_util_has_x11_display_extension (MetaDisplay *display,
+                                      const char  *extension)
+{
+  MetaX11Display *x11_display;
+  Display *xdisplay;
+  int op, event, error;
+
+  x11_display = meta_display_get_x11_display (display);
+  if (!x11_display)
+    return FALSE;
+
+  xdisplay = meta_x11_display_get_xdisplay (x11_display);
+  return XQueryExtension (xdisplay, extension, &op, &event, &error);
+}
diff --git a/src/shell-util.h b/src/shell-util.h
index acd031048f..220606de3b 100644
--- a/src/shell-util.h
+++ b/src/shell-util.h
@@ -66,6 +66,9 @@ gboolean shell_util_stop_systemd_unit  (const char  *unit,
 
 void shell_util_sd_notify (void);
 
+gboolean shell_util_has_x11_display_extension (MetaDisplay *display,
+                                               const char  *extension);
+
 G_END_DECLS
 
 #endif /* __SHELL_UTIL_H__ */


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