Bug#818471: xserver-xorg-input-synaptics: syndaemon not disabling touch pad

2019-06-18 Thread Pavel Reznicek
Package: xserver-xorg-input-synaptics
Version: 1.9.1-1
Followup-For: Bug #818471

Dear Maintainer,

  I am experiencing similar problem. The core of the issue is that some laptops 
have separated touchpad-like driver for the touchpad itself and for the 
buttons. As a result, two touchpad devices can be found in xinput -list. In my 
case these are:

  SYNA3071:00 06CB:82F1 Touchpad
  SynPS/2 Synaptics TouchPad

The synclient and syndaemon programs are taking blindly the first touchpad-like 
device they find, which is unfortunatelly the generic SynPS/2 one. A possible 
dirty workaround is to disable 'psmouse' module, which makes that SynPS/2 
touchpad to disappear, but at the same time the buttons next to the touchpad 
stop (partly) working.

Attached is a patch to the synclient and syndaemon code, which makes sure the 
SynPS/2 device is used only when there is no other touchpad-like device found. 
At the same time a new option "-n device" is added so that user can select (by 
name) which device is to be used by the synclient and syndaemon programs.

Feel free to alter the patch as/if needed.

Best regards,
Pavel
--- old/tools/synclient.c
+++ new/tools/synclient.c
@@ -30,6 +30,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -74,6 +75,8 @@
 int prop_offset;/* Offset inside property */
 };
 
+static const char *dev_substring;
+
 static struct Parameter params[] = {
 {"LeftEdge",  PT_INT,0, 1, SYNAPTICS_PROP_EDGES,   
32, 0},
 {"RightEdge", PT_INT,0, 1, SYNAPTICS_PROP_EDGES,   
32, 1},
@@ -245,12 +248,27 @@
 return dpy;
 }
 
+static void
+dp_get_device_unwind(Atom ** properties, XDevice ** dev, int error, Display * 
dpy, XDeviceInfo * info)
+{
+if ( *properties ) {
+  XFree(*properties);
+  *properties = NULL;
+}
+if ( info ) XFreeDeviceList(info);
+if ( error && (*dev) ) {
+  XCloseDevice(dpy, *dev);
+  *dev = NULL;
+}
+}
+
 static XDevice *
 dp_get_device(Display * dpy)
 {
 XDevice *dev = NULL;
 XDeviceInfo *info = NULL;
 int ndevices = 0;
+int generic_device = -1;
 Atom touchpad_type = 0;
 Atom synaptics_property = 0;
 Atom *properties = NULL;
@@ -267,16 +285,16 @@
 if (!dev) {
 fprintf(stderr, "Failed to open device '%s'.\n",
 info[ndevices].name);
-error = 1;
-goto unwind;
+dp_get_device_unwind(, , error = 1, dpy, NULL);
+continue;
 }
 
 properties = XListDeviceProperties(dpy, dev, );
 if (!properties || !nprops) {
 fprintf(stderr, "No properties on device '%s'.\n",
 info[ndevices].name);
-error = 1;
-goto unwind;
+dp_get_device_unwind(, , error = 1, dpy, NULL);
+continue;
 }
 
 while (nprops--) {
@@ -286,23 +304,41 @@
 if (!nprops) {
 fprintf(stderr, "No synaptics properties on device '%s'.\n",
 info[ndevices].name);
-error = 1;
-goto unwind;
+dp_get_device_unwind(, , error = 1, dpy, NULL);
+continue;
 }
 
-break;  /* Yay, device is suitable */
+fprintf(stderr, "Found  device '%s'.\n", info[ndevices].name);
+
+if ( dev_substring != NULL && strlen(dev_substring) > 0 && 
!strstr(info[ndevices].name, dev_substring) ) {
+fprintf(stderr, " - device '%s' not matching requested 
name '%s'.\n",
+info[ndevices].name, dev_substring);
+dp_get_device_unwind(, , error = 1, dpy, NULL);
+continue;
+}
+
+if ( !strcmp(info[ndevices].name, "SynPS/2 Synaptics TouchPad") ) {
+fprintf(stderr, " - device '%s' is generic one, searching 
for another candidate.\n",
+info[ndevices].name);
+generic_device = ndevices;
+dp_get_device_unwind(, , error = 1, dpy, NULL);
+continue;
+}
+
+fprintf(stderr, "Taking device '%s'.\n", info[ndevices].name);
+error = 0;
+break;   /* Yay, device is suitable */
 }
 }
 
- unwind:
-XFree(properties);
-XFreeDeviceList(info);
-if (!dev)
-fprintf(stderr, "Unable to find a synaptics device.\n");
-else if (error && dev) {
-XCloseDevice(dpy, dev);
-dev = NULL;
+if ( generic_device != -1 && error && !dev ) {
+  fprintf(stderr, "Reverting back to generic device '%s'.\n",
+  info[generic_device].name);
+  dev = XOpenDevice(dpy, info[generic_device].id);
+  error = 0;
 }
+dp_get_device_unwind(, , error, dpy, info);
+
 return dev;
 }
 
@@ -470,6 +506,7 

Bug#818471: xserver-xorg-input-synaptics: syndaemon not disabling touch pad

2016-03-19 Thread Russell Stuart
Package: xserver-xorg-input-synaptics
Version: 1.8.3-1+b1
Severity: normal

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

Syndaemon doesn't disable the touchpad.  It seems to have no effect
whatsoever.

I've tried running if from the command line, using a variety
combinations:

  syndaemon -d -p "/tmp/syndaemon.pid" -i 5 -m 50
  syndaemon -d -i 5 -R
  syndaemon -d -t -R
  syndaemon -d -t -K

I've also tried similar set of combinations when running from
/etc/X11/Xsession.d/98x11-syndaemon:

  # start synaptics daemon to enable proper communication with touchpad
  /usr/bin/syndaemon -d -i 5 -R

Regardless of how it was started, it had no effect.  Testing consisted
typing in gnome-terminal and gvim and moving / tapping the touchpad.

There are two config files under /etc/X11.
/etc/X11/xorg.conf.d/touchpad.conf contains:

  #
  # Turn on two finger scrolling.
  #
  Section "InputClass"
Identifier  "Touchpad twofinger scroll"
MatchIsTouchpad "yes"
Option  "ZAxisMapping"  "4 5"
Option  "HorizTwoFingerScroll"  "true"
Option  "VertTwoFingerScroll"   "true"
Option  "FastTaps"  "on"
Option  "AccelFactor"   "0.1028806" #2x
Option  "MinSpeed"  "1"
Option  "MaxSpeed"  "4.75"
Option  "TapButton1""1"
Option  "TapButton2""3"
Option  "TapButton3""2"
  EndSection

/etc/X11/xorg.conf.d/ctrl-alt-bksp.conf:

  #
  # Turn on control+alt+backspace killing of the X server.
  #
  Section "InputClass"
Identifier  "Enable keyboard ctrl_alt_bksp"
MatchIsKeyboard "yes"
Option  "XkbOptions" "terminate:ctrl_alt_bksp"
  EndSection


An strace of "syndaemon -R -i 5" reveals it is receiving events
from the keyboard, it is sending a command somewhere, waiting 5
seconds, then sending another command that differs by 1 bit.
That's exactly what I would expect, so I suspect the problem
is somewhere else. Here is the strace output:

  20:58:55 recvmsg(4, -{msg_name(0)=NULL, 
msg_iov(1)=[{"\1\0\v\0\10\0\0\0\0\0pa\0\0\0\0\r\rD\0\0\0\0\0_stencil"..., 
4096}], msg_controllen=0, msg_flags=0}, 0) = 64
  20:58:55 recvmsg(4, 0x7ffc5bc8ef70, 0)  = -1 EAGAIN (Resource temporarily 
unavailable)
  20:58:55 poll([{fd=3, events=POLLIN|POLLOUT}], 1, 4294967295) = 1 ([{fd=3, 
revents=POLLOUT}])
  20:58:55 writev(3, [{"\203'\6\0004\1\0\0\23\0\0\0\0\0\0\0\1\0\0\0\17\0\6\0", 
24}, {NULL, 0}, {"", 0}], 3) = 24
  20:58:55 poll([{fd=3, events=POLLIN}], 1, 4294967295) = 1 ([{fd=3, 
revents=POLLIN}])
  20:58:55 recvmsg(3, {msg_name(0)=NULL, 
msg_iov(1)=[{"\1'\310\0\1\0\0\0\23\0\0\0\0\0\0\0\1\0\0\0\10\17\0\0\0\0\0\0\0\0\0\0"...,
 4096}], msg_controllen=0, msg_flags=0}, 0) = 36
  20:58:55 recvmsg(3, 0x7ffc5bc8ee50, 0)  = -1 EAGAIN (Resource temporarily 
unavailable)
  20:58:55 recvmsg(3, 0x7ffc5bc8ee50, 0)  = -1 EAGAIN (Resource temporarily 
unavailable)
  20:58:55 poll([{fd=3, events=POLLIN|POLLOUT}], 1, 4294967295) = 1 ([{fd=3, 
revents=POLLOUT}])
  20:58:55 writev(3, [{"\203%\6\0004\1\0\0\23\0\0\0\17\10\0\0\1\0\0\0\1\0\6\0", 
24}, {NULL, 0}, {"", 0}], 3) = 24
  20:58:55 recvmsg(3, 0x7ffc5bc8ef50, 0)  = -1 EAGAIN (Resource temporarily 
unavailable)
  20:58:55 select(5, [4], NULL, NULL, {5, 0}) = 1 (in [4], left {4, 946654})
  20:58:56 recvmsg(4, {msg_name(0)=NULL, 
msg_iov(1)=[{"\1\0\v\0\10\0\0\0\0\0pa\0\0\0\0D\rD\0\0\0\0\0_stencil"..., 
4096}], msg_controllen=0, msg_flags=0}, 0) = 64
  20:58:56 recvmsg(4, 0x7ffc5bc8ef70, 0)  = -1 EAGAIN (Resource temporarily 
unavailable)
  20:58:56 select(5, [4], NULL, NULL, {5, 0}) = 0 (Timeout)
  20:59:01 poll([{fd=3, events=POLLIN|POLLOUT}], 1, 4294967295) = 1 ([{fd=3, 
revents=POLLOUT}])
  20:59:01 writev(3, [{"\203%\6\0004\1\0\0\23\0\0\0\17\10\0\0\1\0\0\0\0\0\6\0", 
24}, {NULL, 0}, {"", 0}], 3) = 24
  20:59:01 recvmsg(3, 0x7ffc5bc8ef50, 0)  = -1 EAGAIN (Resource temporarily 
unavailable)
  20:59:01 select(5, [4], NULL, NULL, NULL) = 1 (in [4])


- -- Package-specific info:
/etc/X11/X does not exist.
/etc/X11/X is not a symlink.
/etc/X11/X is not executable.

VGA-compatible devices on PCI bus:
- --
00:02.0 VGA compatible controller [0300]: Intel Corporation Skylake Integrated 
Graphics [8086:191b] (rev 06)

/etc/X11/xorg.conf does not exist.

Contents of /etc/X11/xorg.conf.d:
- -
total 8
- -rw-r--r-- 1 root root 210 Feb 12 15:32 ctrl-alt-bksp.conf
- -rw-r--r-- 1 root root 441 Mar 14 13:03 touchpad.conf

/etc/modprobe.d contains no KMS configuration files.

Kernel version (/proc/version):
- ---
Linux version 4.4.0-1-amd64 (debian-ker...@lists.debian.org) (gcc version 5.3.1 
20160205 (Debian 5.3.1-8) ) #1 SMP Debian 4.4.2-3 (2016-02-21)

Xorg X server log files on system:
- --
- -rw-r--r-- 1 root root 29367 Mar 17 20:26 /var/log/Xorg.0.log

Contents of most recent Xorg X server log file (/var/log/Xorg.0.log):
-