summaryrefslogtreecommitdiff
path: root/setxkbmap.c
diff options
context:
space:
mode:
authorOlivier Fourdan <ofourdan@redhat.com>2023-05-09 09:33:36 +0200
committerOlivier Fourdan <ofourdan@redhat.com>2023-05-09 09:38:07 +0200
commit2d3ed3d74cdd4ef6dcf503162a72243ce7a96fb0 (patch)
treec47e21bbc5b42c44ef7c6b8ccb878ca3f9881fe5 /setxkbmap.c
parent9fa24c7ca57665f15dcd1cbe02208bd727e507f7 (diff)
Check for the XWAYLAND extension
With Xwayland 23.1 and above, the definitive way of checking for an Xwayland server is to check for the "XWAYLAND" extension. Keep the old XRandR method for compatibility with older versions of Xwayland. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Diffstat (limited to 'setxkbmap.c')
-rw-r--r--setxkbmap.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/setxkbmap.c b/setxkbmap.c
index d36ee75..21bb12f 100644
--- a/setxkbmap.c
+++ b/setxkbmap.c
@@ -1075,16 +1075,24 @@ is_xwayland(void)
Bool rc = False;
XRRScreenResources *resources = NULL;
XRROutputInfo *output = NULL;
+ int opcode, event_base, error_base, major, minor;
- /* There is no definitive way of checking for an Xwayland server,
- * but the two working methods are:
+ /* With Xwayland 23.1 and above, the definitive way of checking for an
+ * Xwayland server is to check for the "XWAYLAND" extension.
+ */
+ if (XQueryExtension(dpy, "XWAYLAND", &opcode, &event_base, &error_base)) {
+ rc = True;
+ goto out;
+ }
+
+ /* For previous versions of Xwayland, there is no definitive way of checking
+ * for an Xwayland server, but the two working methods are:
* - RandR output names in Xwayland are XWAYLAND0, XWAYLAND1, etc.
* - XI devices are xwayland-pointer:10, xwayland-keyboard:11
* Let's go with the XRandR check here because it's slightly less
* code to write.
*/
- int event_base, error_base, major, minor;
if (!XRRQueryExtension(dpy, &event_base, &error_base) ||
!XRRQueryVersion(dpy, &major, &minor)) {
/* e.g. Xnest, but definitely not Xwayland */