Blame SOURCES/0001-xsetwacom-error-if-we-re-running-this-under-Wayland.patch

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