Compare commits

...

11 Commits

Author SHA1 Message Date
Peter Hutterer
5a925eaa84 xf86-input-libinput 0.28.2
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-02-04 13:14:11 +10:00
Peter Hutterer
e7eafa199e Handle scroll wheel events with a discrete of 0
The driver currently assumes that any wheel event has a non-zero discrete
value of 1. This is incorrect, it just hasn't triggered yet with any device.

With the hi-res scroll patches in place in the kernel and libinput, we may get
wheel events with a discrete value of 0. We assume that if this ever happens,
the device has some sensible click angle set so all we need to do is ignore
the discrete 0 events and wait for the first discrete event to come.

Also add an explanatory comment too to make it clear the calculation is only
done once.

Fixes #19

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-01-25 14:31:11 +10:00
Peter Hutterer
d13ab268bd Return the wheel scroll value instead of just the fraction
This is prep work for the hi-res work but right now, no real functional
changes. It does however fix a bug where we used the vertial scroll dist for
the horizontal wheel as well.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-01-24 08:29:48 +10:00
Peter Hutterer
347c78387e Split the scroll axis details up for easier extension
If we need more per-axis fields, it's easier to add this way.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-01-21 13:08:30 +10:00
Peter Hutterer
b63f7994dc conf: add an example snippet for how to assign options
Users still like to copy the whole file, potentially messing things up.
Let's put a warning into the file directly that this is less than ideal.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-01-07 16:29:51 +10:00
Alan Coopersmith
04f42d6e0f Update configure.ac bug URL for gitlab migration
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2018-11-25 12:47:32 -08:00
Alan Coopersmith
5d341d1d6c Update README for gitlab migration
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2018-11-18 11:48:07 -08:00
Peter Hutterer
4985de5ef3 Remove two dead assignments
Value stored but never read.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-10-15 15:30:55 +10:00
Peter Hutterer
e26fc3c66c xf86-input-libinput 0.28.1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-10-15 09:36:36 +10:00
Peter Hutterer
a759610292 Use the seat slot, not the device slot for touch events
The device slot is per-device, so if we have more than one device we may get a
touch down event for a slot already in use.

Fixes https://gitlab.freedesktop.org/libinput/libinput/issues/153

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-10-04 11:47:46 +10:00
Peter Hutterer
21ff2ca7d1 Remove unused assignment
dev is our list iterator below, this is a dead assignment

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-07-19 15:58:06 +10:00
4 changed files with 80 additions and 49 deletions

View File

@@ -2,7 +2,7 @@ xf86-input-libinput - a libinput-based X driver
===============================================
The official repository for this driver is
http://cgit.freedesktop.org/xorg/driver/xf86-input-libinput/
https://gitlab.freedesktop.org/xorg/driver/xf86-input-libinput
This is an X driver based on libinput. It is a thin wrapper around libinput,
so while it does provide all features that libinput supports it does little
@@ -20,10 +20,10 @@ xorg-x11-server-devel package or similar) and libinput (check your
distribution for libinput-devel or similar).
To get libinput from source, see:
http://www.freedesktop.org/wiki/Software/libinput/
https://www.freedesktop.org/wiki/Software/libinput/
To build the X server from source:
http://www.x.org/wiki/Building_the_X_Window_System/
https://www.x.org/wiki/Building_the_X_Window_System/
Building
--------
@@ -48,8 +48,8 @@ This will assign this driver to *all* devices. Use with caution.
Bugs
----
Bugs in libinput go to the "libinput" component of wayland:
https://bugs.freedesktop.org/enter_bug.cgi?product=Wayland
Bugs in libinput go to the Issues section of the libinput gitlab project:
https://gitlab.freedesktop.org/libinput/libinput/issues
Bugs in this driver go to the "Input/libinput" component of xorg:
https://bugs.freedesktop.org/enter_bug.cgi?product=xorg
Bugs in this driver go to the Issues section of its gitlab project:
https://gitlab.freedesktop.org/xorg/driver/xf86-input-libinput/issues

View File

@@ -1,4 +1,21 @@
# Match on all types of devices but joysticks
#
# If you want to configure your devices, do not copy this file.
# Instead, use a config snippet that contains something like this:
#
# Section "InputClass"
# Identifier "something or other"
# MatchDriver "libinput"
#
# MatchIsTouchpad "on"
# ... other Match directives ...
# Option "someoption" "value"
# EndSection
#
# This applies the option any libinput device also matched by the other
# directives. See the xorg.conf(5) man page for more info on
# matching devices.
Section "InputClass"
Identifier "libinput pointer catchall"
MatchIsPointer "on"

View File

@@ -23,8 +23,8 @@
# Initialize Autoconf
AC_PREREQ([2.60])
AC_INIT([xf86-input-libinput],
[0.28.0],
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
[0.28.2],
[https://gitlab.freedesktop.org/xorg/driver/xf86-input-libinput/issues],
[xf86-input-libinput])
AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_HEADERS([config.h])

View File

@@ -128,11 +128,10 @@ struct xf86libinput {
uint32_t capabilities;
struct {
int vdist;
int hdist;
double vdist_fraction;
double hdist_fraction;
struct scroll_axis {
int dist;
double fraction;
} v, h;
} scroll;
struct {
@@ -398,7 +397,7 @@ xf86libinput_shared_disable(struct xf86libinput_device *shared_device)
libinput_device_set_user_data(device, NULL);
libinput_path_remove_device(device);
device = libinput_device_unref(device);
libinput_device_unref(device);
shared_device->device = NULL;
}
@@ -936,8 +935,8 @@ xf86libinput_init_pointer(InputInfoPtr pInfo)
XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y),
min, max, res * 1000, 0, res * 1000, Relative);
SetScrollValuator(dev, 2, SCROLL_TYPE_HORIZONTAL, driver_data->scroll.hdist, 0);
SetScrollValuator(dev, 3, SCROLL_TYPE_VERTICAL, driver_data->scroll.vdist, 0);
SetScrollValuator(dev, 2, SCROLL_TYPE_HORIZONTAL, driver_data->scroll.h.dist, 0);
SetScrollValuator(dev, 3, SCROLL_TYPE_VERTICAL, driver_data->scroll.v.dist, 0);
return Success;
}
@@ -984,8 +983,8 @@ xf86libinput_init_pointer_absolute(InputInfoPtr pInfo)
XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y),
min, max, res * 1000, 0, res * 1000, Absolute);
SetScrollValuator(dev, 2, SCROLL_TYPE_HORIZONTAL, driver_data->scroll.hdist, 0);
SetScrollValuator(dev, 3, SCROLL_TYPE_VERTICAL, driver_data->scroll.vdist, 0);
SetScrollValuator(dev, 2, SCROLL_TYPE_HORIZONTAL, driver_data->scroll.h.dist, 0);
SetScrollValuator(dev, 3, SCROLL_TYPE_VERTICAL, driver_data->scroll.v.dist, 0);
driver_data->has_abs = TRUE;
@@ -1565,40 +1564,58 @@ xf86libinput_handle_key(InputInfoPtr pInfo, struct libinput_event_keyboard *even
* e.g. a 2 degree click angle requires 8 clicks before a legacy event is
* sent, but each of those clicks will send XI2.1 smooth scroll data for
* compatible clients.
*
* Starting with kernel v5.0 we should get REL_WHEEL_HI_RES from those
* devices for the fine-grained scrolling and REL_WHEEL for the normal one,
* so the use-case above shouldn't matter anymore.
*/
static inline double
get_scroll_fraction(struct xf86libinput *driver_data,
struct libinput_event_pointer *event,
enum libinput_pointer_axis axis)
get_wheel_scroll_value(struct xf86libinput *driver_data,
struct libinput_event_pointer *event,
enum libinput_pointer_axis axis)
{
double *fraction;
struct scroll_axis *s;
double f;
double angle;
int discrete;
switch (axis) {
case LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL:
fraction = &driver_data->scroll.hdist_fraction;
s = &driver_data->scroll.h;
break;
case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL:
fraction = &driver_data->scroll.vdist_fraction;
s = &driver_data->scroll.v;
break;
default:
return 0.0;
}
if (*fraction != 0.0)
return *fraction;
/* Calculate the angle per single scroll event */
angle = libinput_event_pointer_get_axis_value(event, axis);
discrete = libinput_event_pointer_get_axis_value_discrete(event, axis);
/* We only need to guess the fraction on the first set of
* scroll events until a discrete value arrives. Once known, we
* re-use the fraction until the device goes away.
*/
if (s->fraction != 0.0)
goto out;
/* if we get a discrete of 0, assume REL_WHEEL_HI_RES exists and
* normal scroll events are sent correctly, so skip all the
* guesswork.
*/
if (discrete == 0) {
s->fraction = 1.0;
goto out;
}
/* Calculate the angle per single scroll event */
angle /= discrete;
/* We only do magic for click angles smaller than 10 degrees */
if (angle >= 10) {
*fraction = 1.0;
return 1.0;
s->fraction = 1.0;
goto out;
}
/* Figure out something that gets close to 15 degrees (the general
@@ -1609,9 +1626,10 @@ get_scroll_fraction(struct xf86libinput *driver_data,
*/
f = round(15.0/angle);
*fraction = f;
s->fraction = f;
return f;
out:
return s->dist/s->fraction * discrete;
}
static inline bool
@@ -1628,11 +1646,7 @@ calculate_axis_value(struct xf86libinput *driver_data,
source = libinput_event_pointer_get_axis_source(event);
if (source == LIBINPUT_POINTER_AXIS_SOURCE_WHEEL) {
double scroll_fraction;
value = libinput_event_pointer_get_axis_value_discrete(event, axis);
scroll_fraction = get_scroll_fraction(driver_data, event, axis);
value *= driver_data->scroll.vdist/scroll_fraction;
value = get_wheel_scroll_value(driver_data, event, axis);
} else {
value = libinput_event_pointer_get_axis_value(event, axis);
}
@@ -1705,7 +1719,7 @@ xf86libinput_handle_touch(InputInfoPtr pInfo,
if ((driver_data->capabilities & CAP_TOUCH) == 0)
return;
slot = libinput_event_touch_get_slot(event);
slot = libinput_event_touch_get_seat_slot(event);
switch (event_type) {
case LIBINPUT_EVENT_TOUCH_DOWN:
@@ -2092,7 +2106,7 @@ static inline DeviceIntPtr
xf86libinput_find_device_for_tool(InputInfoPtr pInfo,
struct libinput_tablet_tool *tool)
{
struct xf86libinput *dev = pInfo->private;
struct xf86libinput *dev;
struct xf86libinput *driver_data = pInfo->private;
struct xf86libinput_device *shared_device = driver_data->shared_device;
uint64_t serial = libinput_tablet_tool_get_serial(tool);
@@ -3401,8 +3415,8 @@ xf86libinput_pre_init(InputDriverPtr drv,
* affect touchpad scroll speed. For wheels it doesn't matter as
* we're using the discrete value only.
*/
driver_data->scroll.vdist = 15;
driver_data->scroll.hdist = 15;
driver_data->scroll.v.dist = 15;
driver_data->scroll.h.dist = 15;
if (!is_subdevice) {
if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER))
@@ -3624,13 +3638,13 @@ update_mode_prop_cb(ClientPtr client, pointer closure)
groups[idx] = mode;
driver_data->allow_mode_group_updates = true;
rc = XIChangeDeviceProperty(pInfo->dev,
prop_mode_groups,
XA_INTEGER, 8,
PropModeReplace,
val->size,
groups,
TRUE);
XIChangeDeviceProperty(pInfo->dev,
prop_mode_groups,
XA_INTEGER, 8,
PropModeReplace,
val->size,
groups,
TRUE);
driver_data->allow_mode_group_updates = false;
out: