From ba21208fadd9588ef61a6165480ce1092ba7e699 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 10 Dec 2018 11:03:22 +1000 Subject: [PATCH] xsetwacom: error if we're running this under Wayland xsetwacom cannot work under Wayland, even with XWayland because there is no xf86-input-wacom driver. So let's not continue normally and not find any devices because that'll be confusing to the user when the tablet is clearly working. Print an error and exit code of 1. Signed-off-by: Peter Hutterer --- man/xsetwacom.man | 8 ++++++++ tools/xsetwacom.c | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/man/xsetwacom.man b/man/xsetwacom.man index 1c5e445..9674a6b 100644 --- a/man/xsetwacom.man +++ b/man/xsetwacom.man @@ -289,6 +289,14 @@ will require less distance and be more sensitive. Larger values will require more distance and be less sensitive. Default: 1300 or 2600 depending on tablet resolution (corresponds to 13 mm of distance). +.SH WAYLAND SUPPORT + +This tool provides access to the device properties implemented in the +\fBxf86-input-wacom\fR X server input module. It does not work under a +Wayland compositor as the input module is not active. +.TP +See https://github.com/linuxwacom/xf86-input-wacom/wiki/Wayland for details. + .SH "AUTHORS" Peter Hutterer diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c index 8b66944..cb5b7f0 100644 --- a/tools/xsetwacom.c +++ b/tools/xsetwacom.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -2795,6 +2796,24 @@ void argsfromstdin(int *argc, char ***argv) } #endif /* BUILD_FUZZINTERFACE */ +static bool check_for_wayland(Display *dpy) +{ + bool has_xwayland_devices = false; + XDeviceInfo *info; + int ndevices, i; + + info = XListInputDevices(dpy, &ndevices); + for (i = 0; i < ndevices; i++) { + if (strncmp(info[i].name, "xwayland-", 9) == 0) { + has_xwayland_devices = true; + break; + } + } + XFreeDeviceList(info); + + return has_xwayland_devices; +} + int main (int argc, char **argv) { int c; @@ -2880,6 +2899,13 @@ int main (int argc, char **argv) return -1; } + if (check_for_wayland(dpy)) { + fprintf(stderr, + "Wayland devices found but this tool is incompatible with Wayland. See\n" + "https://github.com/linuxwacom/xf86-input-wacom/wiki/Wayland\n"); + return 1; + } + if (!do_list && !do_get && !do_set) { if (optind < argc) -- 2.19.2