Thursday, January 31, 2019

Dell XPS-13 Touchpad problem (analysis and solution)

I recently switched to DELL XPS 13 as my primary laptop. In addition slick design and modern specs, the extra bonus is that there is good Linux support thanks to Dell's Project Sputnik.

However, I quickly discovered that it is plagued by a common problem of random touchpad clicks. It is reported by numerous users and various workarounds were proposed. It exhibits as follows: while I type my touchpad randomly detects a click and my cursor jumps to a random position in the text while I continue typing. Pressing Ctrl-Z and re-typing from the last good position becomes a reflex you exercise a hundred times a day. It is so annoying I was considering going back to my old laptop.

I never had this problem on my previous laptop (Lenovo X260) or on several MacBook's I've owned before that. Both Lenovo and DELL are using Synaptic touchpad with the same driver. I decided to investigate.

I am right-handed and I while typing sometimes I reach with my right hand to left side of the keyboard. For example, to type $ sign, I hold left SHIFT button with my left thumb and reach to $ with my right hand's index finger. Doing this puts my thumb above the touchpad which in my theory could be causing an erroneous click. Perhaps this is not a proper typing technique but it is too late for me to change my habits.

Now, let us look at touchpad location for both laptops:

Lenovo X260
Dell XPS 13

And superimpose their respective touchpad/keyboard layouts:

As you can see Lenovo's touchpad is narrower and positioned to the left off center. Also, it has two physical buttons on the top, which I never use, but they put active touchpad area further from the spacebar vertically. Kudo's their ergonomic team!

So, how do I fix this? We can use synclient(1) utility to adjust the size of DELL's touchpad active area. First, the geometry of the touchpad could be queried with the following command (the values may be different on our computer):

$ synclient -l                                        
Parameter settings:
    LeftEdge                = 48
    RightEdge               = 1168
    TopEdge                 = 36
    BottomEdge              = 644

The origin of the coordinate system (0,0) is in the upper right corner with X-axis extending to the right and Y away from the screen. Now we can move the right and bottom edges a bit with the following commands:

$ synclient AreaRightEdge=1000
$ synclient AreaTopEdge=130  
$ synclient PalmDetect=1

We've moved the right edge from 1168 to 1000, cutting off a vertical stripe 1168 pixels wide. Also, we've moved the top from 36 to 130, cutting off the horizontal strip 94 pixels high. We've also enabled palm detection, for the cases where you still manage to touch the touchpad with part of your palm. The changes to the geometry are shown below. The part shown in red is no longer sensitive to touches. 

These numbers work for me but you may need to adjust for your liking. It does not fully eliminate the problem but certainly makes things better, at least for me.

P.S. There is a known issue with 2 touchpad drivers activated at the same time. From this forum post:

If command `xinput --list` shows something like this:

⎡ Virtual core pointer  id=2 [master pointer (3)]
⎜   ↳ Virtual core XTEST pointer  id=4 [slave pointer (2)]
⎜   ↳ ELAN24F0:00 04F3:24F0  id=12 [slave pointer (2)]
⎜   ↳ DELL07E6:00 06CB:76AF Touchpad  id=13 [slave pointer (2)]
⎜   ↳ SynPS/2 Synaptics TouchPad id=14    [slave pointer (2)]

   Which includes two touchpad devices, one needs to be disabled. Use following commands:

   cd /etc/X11
   sudo mkdir xorg.conf.d
   cd xorg.conf.d/
   sudo vi 51-synaptics.conf

Then type:

   Section "InputClass"
   Identifier "touchpad ignore SynPS/2 Synaptics duplicate"
   MatchProduct "SynPS/2 Synaptics TouchPad" 
   Option "Ignore" "on" 
   Then, restart X11.