diff --git a/src/shell-util.c b/src/shell-util.c index f344ec50b..918dcdf0b 100644 --- a/src/shell-util.c +++ b/src/shell-util.c @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include #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 acd031048..220606de3 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__ */