chiark / gitweb /
Sensitivity: Handle sensitivities < 1.0 without rounding errors
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 24 Apr 2016 01:36:01 +0000 (02:36 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 26 Apr 2016 20:06:50 +0000 (21:06 +0100)
commit0a2233adf927138220bc05dbe3686091ea931367
treefba32e5327ff8cbe84b5e1e3f80c60793fa982e4
parent919177454d4874c57e327e76fa74a8c7f946810f
Sensitivity: Handle sensitivities < 1.0 without rounding errors

Background: We tell the xf86 core that our x and y ranges are the
overall range of the trackpad.  The xf86 core scales the supplied
values in the same way for relative and absolute pointers.  The result
is that at sensitivity 1.0, the scale of the whole trackpad
corresponds to the scale of the whole screen (so for example moving
the pointer from the very LHS to the very RHS of the screen can be
achieved by moving a finger from the very LHS to the very RHS of the
trackpad).

On some modern machines the resolution of the screen is much higher
than the resolution of the trackpad.  When this occurs, due to
rounding error, it can be impossible to reach the bottom and right
edges of the screen.  This is because even a 1-unit movement on the
trackpad is multipled by a >1-pixel pointer movement, and pointer
movements which would take the pointer off the screen are ignored.
(Arguably this is some kind of bug.)  In any case the user will
probably want to be able to control the pointer position with 1-pixel
accuracy.

This requires mtrack to specify a higher resolution.  Otherwise, the
fact that the values provided by mtrack to xf86 are integers means
that attempts to set the sensitivity to values < 1.0 are not properly
effective - resulting in "lumpy" response.

Fix this as follows:

 * Split sensitivity_val into sensitivity_big and _smalldiv,
   both >= 1.0, such that sensitivity_big/sensitivity_smalldiv is the
   specified sensitivity.

 * Multiply the size we tell xf86 by sensitivity_smalldiv.

As a result, when sensitivity is < 1.0, instead of scaling down
motions (resulting in unwanted rounding), we scale up the nominal size
(resulting in a lower scaling factor being applied by xf86).

When the sensitivity is > 1.0, everything behaves as before.

There is no change to the visible configuration.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
driver/mtrack.c
include/mconfig.h
src/gestures.c
src/mconfig.c