Skip to content

dix: switch scroll button emulation to multiples of increment

Marking this as draft because I need a lot more time to remember whether last.valuators as used here is reliable. Plus to check if this can have a negative side-effect on Xorg.

But it should be good enough for testing and verifying if it indeed Fixes #1339 (closed).

Anyway, see the commit message, there is a significant drawback to this approach but I don't know how we can fix this, short of adding heuristics.


The current algorithm triggers a bug in Xwayland when two devices have different granularity of scrolling. In Xwayland, the scroll increment is 1 and all physical devices scroll through the same (x)wayland pointer device.

This may cause events to get lost when changing devices:

  • mouse scrolls by full increment, current value is 1.0
    • last scroll button was sent for valuator value 0.0
    • delta is 1.0 and we emulate a button event.
  • touchpad scrolls by partial increment, current value is 1.3
    • last scroll button was sent for valuator value 1.0,
    • delta is 0.3 and no button event is emulated
  • mouse scrolls by full increment, current value is -0.7,
    • last scroll button was sent for valuator value 1.0,
    • delta is -0.7 and no button event is emulated

Thus the wheel event appears to get lost. Xwayland cannot reliably detect this case because we don't see the physical devices.

We can work around this by instead emulating buttons whenever we cross a multiple of increment. However, this has a drawback: high-resolution scroll devices can now trigger a button event storm by jittering across the multiple of increment. e.g. in the example above the touchpad moving from 1.3 to 1.0 would cause a click, despite this being a third of an increment.

Fixes #1339 (closed)

Edited by Peter Hutterer

Merge request reports