Let (wacom) tablet control the regular wl_pointer for apps that do not implement tablet_v2 protocol
Feature summary
Currently, input events from a (wacom) tablet are processed by mutter and exposed to clients exclusively through the tablet-unstable-v2 protocol (controlling a second pointer independent on the main wl_pointer). Wayland clients that are not interested in the extra detail (i.e. pressure levels, proximity events) provided by this protocol might not implement it, which prevents using the tablet as a regular pointing device on these applications.
I would like to see mutter handle this situation by, for these applications, letting the tablet stylus actually control the main pointer and exposing its movement and button events through the normal wl_pointer protocol.
How would you like it to work
Basically, I think it comes down to:
- If a client has requested the tablet-unstable-v2 protocol, mark all of its surfaces as "supports tablet events"
- When an event happens and the cursor is on top of a surface that supports tablet events, send a tablet-unstable-v2 event. If not, send a regular wl_pointer event.
- When dragging, some additional consideration is needed to ensure that subsequent motion and button up events are sent out through the same interface as the starting button down event(s).
- When sending an event through the wl_pointer interface, make sure to translate
BTN_STYLUS
button numbers to the appropriateBTN_LEFT
/BTN_RIGHT
/BTN_MIDDLE
(and maybe alsoBTN_BACK
/BTN_FORWARD
if configured, but see #2225 for some possible caveats about back and forward).
Sway actually implements this already, see e.g. https://github.com/swaywm/sway/blob/440d0bc22d57b8b0b21a8acbf127243b8d08cfae/sway/input/cursor.c#L645-L654 and https://github.com/swaywm/sway/blob/440d0bc22d57b8b0b21a8acbf127243b8d08cfae/sway/input/cursor.c#L736-L757 and https://github.com/swaywm/sway/blob/440d0bc22d57b8b0b21a8acbf127243b8d08cfae/sway/input/cursor.c#L821-L845 (though I think it only implements the consideration of 3. above for the tip, not additional buttons, which I think might be needed).
See also #2225 and #1916 (closed) where this came up.