[PATCH libinput 1/2] tools: add --disable-sendevents option to the debug-events/debug-gui tools

Peter Hutterer peter.hutterer at who-t.net
Sun Sep 10 23:42:28 UTC 2017


Makes it possible to debug issues with sendevents.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 tools/libinput-debug-events.man |  3 +++
 tools/shared.c                  | 19 +++++++++++++++++++
 tools/shared.h                  |  3 +++
 3 files changed, 25 insertions(+)

diff --git a/tools/libinput-debug-events.man b/tools/libinput-debug-events.man
index 473e064c..abccfa66 100644
--- a/tools/libinput-debug-events.man
+++ b/tools/libinput-debug-events.man
@@ -44,6 +44,9 @@ The default behavior is equivalent to \-\-udev "seat0".
 Use verbose output
 .SS libinput configuration options
 .TP 8
+.B \-\-disable-sendevents="pattern"
+Set the send-events option to disabled for the devices matching patterns.
+.TP 8
 .B \-\-enable\-tap|\-\-disable\-tap
 Enable or disable tap-to-click
 .TP 8
diff --git a/tools/shared.c b/tools/shared.c
index 8039de9b..ae3287ba 100644
--- a/tools/shared.c
+++ b/tools/shared.c
@@ -25,6 +25,7 @@
 
 #include <errno.h>
 #include <fcntl.h>
+#include <fnmatch.h>
 #include <getopt.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -208,6 +209,15 @@ tools_parse_option(int option,
 			else
 			      return 1;
 			break;
+		case OPT_DISABLE_SENDEVENTS:
+			if (!optarg)
+				return 1;
+
+			snprintf(options->disable_pattern,
+				 sizeof(options->disable_pattern),
+				 "%s",
+				 optarg);
+			break;
 	}
 
 	return 0;
@@ -367,6 +377,15 @@ tools_device_apply_config(struct libinput_device *device,
 			libinput_device_config_accel_set_profile(device,
 								 options->profile);
 	}
+
+	if (libinput_device_config_send_events_get_modes(device) &
+	      LIBINPUT_CONFIG_SEND_EVENTS_DISABLED &&
+	    fnmatch(options->disable_pattern,
+		    libinput_device_get_name(device),
+		   0) !=  FNM_NOMATCH) {
+		libinput_device_config_send_events_set_mode(device,
+					    LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
+	}
 }
 
 static char*
diff --git a/tools/shared.h b/tools/shared.h
index ceaa08a9..55e15409 100644
--- a/tools/shared.h
+++ b/tools/shared.h
@@ -49,9 +49,11 @@ enum configuration_options {
 	OPT_SCROLL_BUTTON,
 	OPT_SPEED,
 	OPT_PROFILE,
+	OPT_DISABLE_SENDEVENTS,
 };
 
 #define CONFIGURATION_OPTIONS \
+	{ "disable-sendevents",        required_argument, 0, OPT_DISABLE_SENDEVENTS }, \
 	{ "enable-tap",                no_argument,       0, OPT_TAP_ENABLE }, \
 	{ "disable-tap",               no_argument,       0, OPT_TAP_DISABLE }, \
 	{ "enable-drag",               no_argument,       0, OPT_DRAG_ENABLE }, \
@@ -92,6 +94,7 @@ struct tools_options {
 	double speed;
 	int dwt;
 	enum libinput_config_accel_profile profile;
+	char disable_pattern[64];
 };
 
 void tools_init_options(struct tools_options *options);
-- 
2.13.5



More information about the wayland-devel mailing list