Commit f139f142 authored by Peter Hutterer's avatar Peter Hutterer

Add an option to disable horizontal scrolling

libinput always has horizontal scrolling enabled and punts the decision when
to scroll horizontally to the toolkit/widget. This is the better approach, but
while we have a stack that's not ready for that, and in the X case likely
never will be fully ready provide an option to disable horizontal scrolling.

This option doesn't really disable horizontal scrolling, it merely discards
any horizontal scroll delta. libinput will still think it's scrolling.

https://bugs.freedesktop.org/show_bug.cgi?id=91589Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: 's avatarHans de Goede <hdegoede@redhat.com>
parent e3a888c3
......@@ -120,4 +120,8 @@
the target button number */
#define LIBINPUT_PROP_DRAG_LOCK_BUTTONS "libinput Drag Lock Buttons"
/* Horizontal scroll events enabled: BOOL, 1 value (0 or 1).
* If disabled, horizontal scroll events are discarded */
#define LIBINPUT_PROP_HORIZ_SCROLL_ENABLED "libinput Horizonal Scroll Enabled"
#endif /* _LIBINPUT_PROPERTIES_H_ */
......@@ -107,6 +107,12 @@ Enables a scroll method. Permitted values are
Not all devices support all options, if an option is unsupported, the
default scroll option for this device is used.
.TP 7
.BI "Option \*qHorizontalScrolling\*q" bool \*q
Disables horizontal scrolling. When disabled, this driver will discard any
horizontal scroll events from libinput. Note that this does not disable
horizontal scrolling, it merely discards the horizontal axis from any scroll
events.
.TP 7
.BI "Option \*qSendEventsMode\*q \*q" (disabled|enabled|disabled-on-external-mouse) \*q
Sets the send events mode to disabled, enabled, or "disable when an external
mouse is connected".
......@@ -226,6 +232,10 @@ Either one 8-bit value specifying the meta drag lock button, or a list of
button pairs. See section
.B BUTTON DRAG LOCK
for details.
.TP 7
.BI "libinput Horizontal Scrolling Enabled"
1 boolean value (8 bit, 0 or 1). Indicates whether horizontal scrolling
events are enabled or not.
.SH BUTTON MAPPING
X clients receive events with logical button numbers, where 1, 2, 3
......
......@@ -111,6 +111,8 @@ struct xf86libinput {
enum libinput_config_click_method click_method;
unsigned char btnmap[MAX_BUTTONS + 1];
BOOL horiz_scrolling_enabled;
} options;
struct draglock draglock;
......@@ -831,6 +833,10 @@ xf86libinput_handle_axis(InputInfoPtr pInfo, struct libinput_event_pointer *even
}
valuator_mask_set_double(mask, 3, value);
}
if (!driver_data->options.horiz_scrolling_enabled)
goto out;
axis = LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL;
if (libinput_event_pointer_has_axis(event, axis)) {
if (source == LIBINPUT_POINTER_AXIS_SOURCE_WHEEL) {
......@@ -842,6 +848,7 @@ xf86libinput_handle_axis(InputInfoPtr pInfo, struct libinput_event_pointer *even
valuator_mask_set_double(mask, 2, value);
}
out:
xf86PostMotionEventM(dev, Relative, mask);
}
......@@ -1425,6 +1432,12 @@ xf86libinput_parse_draglock_option(InputInfoPtr pInfo,
free(str);
}
static inline BOOL
xf86libinput_parse_horiz_scroll_option(InputInfoPtr pInfo)
{
return xf86SetBoolOption(pInfo->options, "HorizontalScrolling", TRUE);
}
static void
xf86libinput_parse_options(InputInfoPtr pInfo,
struct xf86libinput *driver_data,
......@@ -1450,8 +1463,10 @@ xf86libinput_parse_options(InputInfoPtr pInfo,
xf86libinput_parse_buttonmap_option(pInfo,
options->btnmap,
sizeof(options->btnmap));
if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER))
if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER)) {
xf86libinput_parse_draglock_option(pInfo, driver_data);
options->horiz_scrolling_enabled = xf86libinput_parse_horiz_scroll_option(pInfo);
}
}
static int
......@@ -1647,6 +1662,7 @@ static Atom prop_disable_while_typing_default;
/* driver properties */
static Atom prop_draglock;
static Atom prop_horiz_scroll;
/* general properties */
static Atom prop_float;
......@@ -2166,6 +2182,33 @@ LibinputSetPropertyDragLockButtons(DeviceIntPtr dev,
val->size, checkonly);
}
static inline int
LibinputSetPropertyHorizScroll(DeviceIntPtr dev,
Atom atom,
XIPropertyValuePtr val,
BOOL checkonly)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
struct xf86libinput *driver_data = pInfo->private;
BOOL enabled;
if (val->format != 8 || val->type != XA_INTEGER || val->size != 1)
return BadMatch;
enabled = *(BOOL*)val->data;
if (checkonly) {
if (enabled != 0 && enabled != 1)
return BadValue;
if (!xf86libinput_check_device (dev, atom))
return BadMatch;
} else {
driver_data->options.horiz_scrolling_enabled = enabled;
}
return Success;
}
static int
LibinputSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
BOOL checkonly)
......@@ -2205,6 +2248,8 @@ LibinputSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
rc = LibinputSetPropertyDisableWhileTyping(dev, atom, val, checkonly);
else if (atom == prop_draglock)
rc = LibinputSetPropertyDragLockButtons(dev, atom, val, checkonly);
else if (atom == prop_horiz_scroll)
rc = LibinputSetPropertyHorizScroll(dev, atom, val, checkonly);
else if (atom == prop_device || atom == prop_product_id ||
atom == prop_tap_default ||
atom == prop_tap_drag_lock_default ||
......@@ -2703,6 +2748,18 @@ LibinputInitDragLockProperty(DeviceIntPtr dev,
sz, dl_values);
}
static void
LibinputInitHorizScrollProperty(DeviceIntPtr dev,
struct xf86libinput *driver_data)
{
BOOL enabled = driver_data->options.horiz_scrolling_enabled;
prop_horiz_scroll = LibinputMakeProperty(dev,
LIBINPUT_PROP_HORIZ_SCROLL_ENABLED,
XA_INTEGER, 8,
1, &enabled);
}
static void
LibinputInitProperty(DeviceIntPtr dev)
{
......@@ -2754,4 +2811,5 @@ LibinputInitProperty(DeviceIntPtr dev)
XISetDevicePropertyDeletable(dev, prop_product_id, FALSE);
LibinputInitDragLockProperty(dev, driver_data);
LibinputInitHorizScrollProperty(dev, driver_data);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment