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
This commit is contained in:
Jonas Ådahl 2019-10-01 11:55:33 +02:00
parent 059fb5c7cb
commit 7220f6d25b
2 changed files with 29 additions and 0 deletions

View File

@ -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);
}

View File

@ -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__ */