Bug#873523: libinput-bin: After resuming touchpad is enabled although in settings is disabled

2017-09-28 Thread Iain Lane
Control: tags -1 + patch confirmed upstream

On Mon, Aug 28, 2017 at 07:00:58PM +0100, Benny Arana wrote:
>* What led up to the situation?
>   After switching to wayland (since last release in testing), the 
> suspend-resume cycle re-enables the touchpad.
>   I disabled the touchpad in 'mouse & touchpad' settings but after 
> resuming from suspending the touchpad is enabled although in settings it 
> remains disabled.
> 
>   Just to test if all settings are being ignored or just the touchpad 
> enable/disable config, I changed the default values to see if the config was 
> going back to them but this is not the case. Just the touchpad enable/disable 
> config is being ignored. 

[...]

I just tracked this down for Ubuntu - it's fixed upstream. Here's a
patch for the libinput maintainers to apply if they'd like.

Cheers,

-- 
Iain Lane  [ i...@orangesquash.org.uk ]
Debian Developer   [ la...@debian.org ]
Ubuntu Developer   [ la...@ubuntu.com ]
From 03f13ce6e854b3ff5d4b8971405a97afd66eef8e Mon Sep 17 00:00:00 2001
From: Peter Hutterer 
Date: Tue, 5 Sep 2017 14:38:53 +1000
Subject: [PATCH libinput] touchpad: don't resume a disabled touchpad

Signed-off-by: Peter Hutterer 
---
 src/evdev-mt-touchpad.c | 44 ++--
 test/test-lid.c | 78 +
 2 files changed, 107 insertions(+), 15 deletions(-)

diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 5b8fb1ec..c0a78255 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -1426,6 +1426,31 @@ tp_resume(struct tp_dispatch *tp, struct evdev_device *device)
 	}
 }
 
+#define NO_EXCLUDED_DEVICE NULL
+static void
+tp_resume_conditional(struct tp_dispatch *tp,
+		  struct evdev_device *device,
+		  struct evdev_device *excluded_device)
+{
+	if (tp->sendevents.current_mode == LIBINPUT_CONFIG_SEND_EVENTS_DISABLED)
+		return;
+
+	if (tp->sendevents.current_mode ==
+		LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE) {
+		struct libinput_device *dev;
+
+		list_for_each(dev, >base.seat->devices_list, link) {
+			struct evdev_device *d = evdev_device(dev);
+			if (d != excluded_device &&
+			(d->tags & EVDEV_TAG_EXTERNAL_MOUSE)) {
+return;
+			}
+		}
+	}
+
+	tp_resume(tp, device);
+}
+
 static void
 tp_trackpoint_timeout(uint64_t now, void *data)
 {
@@ -1667,7 +1692,7 @@ tp_lid_switch_event(uint64_t time, struct libinput_event *event, void *data)
 	swev = libinput_event_get_switch_event(event);
 	switch (libinput_event_switch_get_switch_state(swev)) {
 	case LIBINPUT_SWITCH_STATE_OFF:
-		tp_resume(tp, tp->device);
+		tp_resume_conditional(tp, tp->device, NO_EXCLUDED_DEVICE);
 		evdev_log_debug(tp->device, "lid: resume touchpad\n");
 		break;
 	case LIBINPUT_SWITCH_STATE_ON:
@@ -1722,7 +1747,6 @@ tp_interface_device_removed(struct evdev_device *device,
 			struct evdev_device *removed_device)
 {
 	struct tp_dispatch *tp = (struct tp_dispatch*)device->dispatch;
-	struct libinput_device *dev;
 
 	if (removed_device == tp->buttons.trackpoint) {
 		/* Clear any pending releases for the trackpoint */
@@ -1749,19 +1773,9 @@ tp_interface_device_removed(struct evdev_device *device,
 		tp->lid_switch.lid_switch = NULL;
 	}
 
-	if (tp->sendevents.current_mode !=
-	LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE)
-		return;
-
-	list_for_each(dev, >base.seat->devices_list, link) {
-		struct evdev_device *d = evdev_device(dev);
-		if (d != removed_device &&
-		(d->tags & EVDEV_TAG_EXTERNAL_MOUSE)) {
-			return;
-		}
-	}
-
-	tp_resume(tp, device);
+	/* removed_device is still in the device list at this point, so we
+	 * need to exclude it from the tp_resume_conditional */
+	tp_resume_conditional(tp, device, removed_device);
 }
 
 static inline void
diff --git a/test/test-lid.c b/test/test-lid.c
index 4bf4c059..7e42f53d 100644
--- a/test/test-lid.c
+++ b/test/test-lid.c
@@ -342,6 +342,81 @@ START_TEST(lid_disable_touchpad_already_open)
 }
 END_TEST
 
+START_TEST(lid_dont_resume_disabled_touchpad)
+{
+	struct litest_device *sw = litest_current_device();
+	struct litest_device *touchpad;
+	struct libinput *li = sw->libinput;
+
+	touchpad = lid_init_paired_touchpad(li);
+	litest_disable_tap(touchpad->libinput_device);
+	libinput_device_config_send_events_set_mode(touchpad->libinput_device,
+		LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
+	litest_drain_events(li);
+
+	/* switch is on - no events */
+	litest_lid_action(sw, LIBINPUT_SWITCH_STATE_ON);
+	litest_assert_only_typed_events(li, LIBINPUT_EVENT_SWITCH_TOGGLE);
+
+	litest_touch_down(touchpad, 0, 50, 50);
+	litest_touch_move_to(touchpad, 0, 50, 50, 70, 50, 10, 1);
+	litest_touch_up(touchpad, 0);
+	litest_assert_empty_queue(li);
+
+	/* switch is off - motion events */
+	litest_lid_action(sw, LIBINPUT_SWITCH_STATE_OFF);
+	

Bug#873523: libinput-bin: After resuming touchpad is enabled although in settings is disabled

2017-08-28 Thread Benny Arana
Package: libinput-bin
Version: 1.8.0-1
Severity: normal

Dear Maintainer,

   * What led up to the situation?
After switching to wayland (since last release in testing), the 
suspend-resume cycle re-enables the touchpad.
I disabled the touchpad in 'mouse & touchpad' settings but after 
resuming from suspending the touchpad is enabled although in settings it 
remains disabled.

Just to test if all settings are being ignored or just the touchpad 
enable/disable config, I changed the default values to see if the config was 
going back to them but this is not the case. Just the touchpad enable/disable 
config is being ignored. 


Other related packages:
ii gnome-shell 3.22.3-3
ii xwayland  2:1.19.3-2
ii libinput10:amd64 1.8.0-1




-- System Information:
Debian Release: buster/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.12.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_GB:en (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages libinput-bin depends on:
ii  libc6  2.24-14
ii  libudev1   234-2.3
ii  libwacom2  0.24-1

libinput-bin recommends no packages.

libinput-bin suggests no packages.

-- debconf-show failed