From d0a77e79a73177090ae7dceb7a9802f98db6d9f0 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 26 Mar 2019 16:06:44 +1000 Subject: Warn if you're running against an XWayland server Because there's a 99% chance you don't want this. Signed-off-by: Peter Hutterer --- man/xinput.man | 18 ++++++++++++++++++ src/xinput.c | 23 +++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/man/xinput.man b/man/xinput.man index b89fb01..a9b2148 100644 --- a/man/xinput.man +++ b/man/xinput.man @@ -178,6 +178,24 @@ by the new value(s) of the property. For example: .IP \fBxinput set-prop "my device" "my prop" 1 2 3\fB +.SH "XWAYLAND" +Xwayland is an X server that uses a Wayland Compositor as backend. +Xwayland acts as translation layer between the X protocol and the Wayland +protocol but does not have direct access to the hardware. The X Input +Extension devices created by Xwayland ("xwayland-pointer", +"xwayland-keyboard", etc.) map to the Wayland protocol devices, +not to physical devices. +.PP +These X Input Extension devices are only visible to other X clients +connected to the same Xwayland process. Changing properties on Xwayland +devices only affects the behavior of those clients. For example, disabling +an Xwayland device with xinput does not disable the device in Wayland-native +applications. Other changes may not have any effect at all. +.PP +In most instances, using xinput with an Xwayland device is indicative of a +bug in a shell script and xinput will print a warning. Use the Wayland +Compositor's native device configuration methods instead. + .SH "SEE ALSO" X(__miscmansuffix__), xset(__appmansuffix__), xrandr(__appmansuffix__) .SH COPYRIGHT diff --git a/src/xinput.c b/src/xinput.c index 5dd2766..7b27ffe 100644 --- a/src/xinput.c +++ b/src/xinput.c @@ -361,6 +361,26 @@ usage(void) } } +static Bool +is_xwayland(Display *dpy) +{ + XDeviceInfo *devices; + int n; + Bool is_xwayland = False; + + devices = XListInputDevices(dpy, &n); + while (n-- > 0) { + if (strncmp(devices[n].name, "xwayland-", 9) == 0) { + is_xwayland = True; + break; + } + } + + XFreeDeviceList(devices); + + return is_xwayland; +} + int main(int argc, char * argv[]) { @@ -402,6 +422,9 @@ main(int argc, char * argv[]) goto out; } + if (is_xwayland(display)) + fprintf(stderr, "WARNING: running xinput against an Xwayland server. See the xinput man page for details.\n"); + while(driver->func_name) { if (strcmp(driver->func_name, func) == 0) { int r = (*driver->func)(display, argc-2, argv+2, -- cgit v1.2.3