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 <peter.hutte...@who-t.net>
Date: Tue, 5 Sep 2017 14:38:53 +1000
Subject: [PATCH libinput] touchpad: don't resume a disabled touchpad

Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
---
 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

Bug#782272: FTBFS with libc6-dev = 2.21: /usr/include/xorg/os.h:579:1: error: expected identifier or '(' before '__extension__' strndup(const char *str, size_t n);

2015-04-09 Thread Iain Lane
Package: xserver-xorg-input-vmmouse
Version: 1:13.0.0
Severity: minor
Tags: patch upstream fixed-upstream

Hi,

We noticed in Ubuntu that vmmouse fails with the new glibc which is in
experimental currently:

  sbuild -d experimental --add-depends=libc6-dev (= 2.20) -A 
--build-dep-resolver=aptitude xserver-xorg-input-vmmouse_13.0.0-1.dsc

  make[3]: Entering directory '/«PKGBUILDDIR»/build/shared'
  /bin/bash ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. 
-I../../shared -I..  -fvisibility=hidden -I/usr/include/pixman-1 
-I/usr/include/libdrm -I/usr/include/xorg -I/usr/include/X11/dri-g -O2 -c 
-o vmmouse_client.lo ../../shared/vmmouse_client.c
  libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../shared -I.. 
-fvisibility=hidden -I/usr/include/pixman-1 -I/usr/include/libdrm 
-I/usr/include/xorg -I/usr/include/X11/dri -g -O2 -c 
../../shared/vmmouse_client.c  -fPIC -DPIC -o .libs/vmmouse_client.o
  In file included from /usr/include/string.h:634:0,
   from /usr/include/xorg/os.h:53,
   from /usr/include/xorg/misc.h:115,
   from /usr/include/xorg/window.h:50,
   from /usr/include/xorg/globals.h:7,
   from /usr/include/xorg/opaque.h:34,
   from /usr/include/xorg/xf86_OSproc.h:127,
   from ../../shared/vmmouse_client.h:42,
   from ../../shared/vmmouse_client.c:38:
  /usr/include/xorg/os.h:579:1: error: expected identifier or '(' before 
'__extension__'
   strndup(const char *str, size_t n);
   ^
  make[3]: *** [vmmouse_client.lo] Error 1

Fixed by the attached upstream patch.

Cheers,

-- 
Iain Lane  [ i...@orangesquash.org.uk ]
Debian Developer   [ la...@debian.org ]
Ubuntu Developer   [ la...@ubuntu.com ]
From 1cbbc03c4b37d57760c57bd2e0b0f89d744a5795 Mon Sep 17 00:00:00 2001
From: Stefan Dirsch sndir...@suse.de
Date: Tue, 7 Oct 2014 11:32:01 +0200
Subject: [PATCH] vmmouse_client.h: Include xorg-server.h before xf86_OSproc.h

xf86_OSproc.h cannot be included without first including xorg-server.h.

Without this the build fails on systems with the latest glibc,
throwing this error:

In file included from /usr/include/string.h:634:0,
 from /usr/include/xorg/os.h:53,
 from /usr/include/xorg/misc.h:115,
 from /usr/include/xorg/window.h:50,
 from /usr/include/xorg/globals.h:7,
 from /usr/include/xorg/opaque.h:34,
 from /usr/include/xorg/xf86_OSproc.h:127,
 from vmmouse_client.h:42,
 from vmmouse_client.c:38:
/usr/include/xorg/os.h:579:1: error: expected identifier or '(' before '__extension__'
strndup(const char *str, size_t n);

This is caused by HAVE_STRNDUP not being set (it is set from xorg-server.h),
causing os.h to redefine it.

Signed-off-by: Stefan Dirsch sndir...@suse.de
Reviewed-by: Daniel Stone dani...@collabora.com
Acked-by: Thomas Hellstrom thellst...@vmware.com
---
 shared/vmmouse_client.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/shared/vmmouse_client.h b/shared/vmmouse_client.h
index b01bf08..1de51e5 100644
--- a/shared/vmmouse_client.h
+++ b/shared/vmmouse_client.h
@@ -39,6 +39,7 @@
 #ifndef _VMMOUSE_CLIENT_H_
 #define _VMMOUSE_CLIENT_H_
 
+#include xorg-server.h
 #include xf86_OSproc.h
 
 /*
-- 
2.1.4