[gnome-shell/wip/rstrode/login-screen-extensions: 98/134] shell-util: Add API to check for X11 extensions




commit 68f5f37d8368ac94f86b311e8892aeeadbaa999e
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 31bb18e70a..fa3fc08c86 100644
--- a/src/shell-util.c
+++ b/src/shell-util.c
@@ -21,6 +21,8 @@
 #include <gtk/gtk.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 #include <meta/meta-shaped-texture.h>
+#include <meta/display.h>
+#include <meta/meta-x11-display.h>
 
 #include <locale.h>
 #ifdef HAVE__NL_TIME_FIRST_WEEKDAY
@@ -613,3 +615,27 @@ shell_util_check_cloexec_fds (void)
   fdwalk (check_cloexec, NULL);
   g_info ("Open fd CLOEXEC check complete");
 }
+
+/**
+ * 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 6904f43bc3..02b8404e9e 100644
--- a/src/shell-util.h
+++ b/src/shell-util.h
@@ -59,6 +59,9 @@ cairo_surface_t * shell_util_composite_capture_images (ClutterCapture  *captures
 
 void shell_util_check_cloexec_fds (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]