diff options
author | Olivier Fourdan <ofourdan@redhat.com> | 2023-05-09 09:33:36 +0200 |
---|---|---|
committer | Olivier Fourdan <ofourdan@redhat.com> | 2023-05-09 09:38:07 +0200 |
commit | 2d3ed3d74cdd4ef6dcf503162a72243ce7a96fb0 (patch) | |
tree | c47e21bbc5b42c44ef7c6b8ccb878ca3f9881fe5 | |
parent | 9fa24c7ca57665f15dcd1cbe02208bd727e507f7 (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>
-rw-r--r-- | setxkbmap.c | 14 |
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 */ |