Skip to content

Implement support for tablet tool keybindings and actions

Peter Hutterer requested to merge whot/mutter:wip/stylus-button-mapping into main

Requires gsettings-desktop-schemas!76 (merged) for the gsettings.

Sits on top of !3647 (merged)

Notes on the implementation: The approach I've chosen here is for stylus button mapped to a non-button action to create a CLUTTER_BUTTON_PRESS/RELEASE event with a clutter button of zero. That one is filtered during meta_display_handle_event() and only makes it as far as the new MetaToolActionMapper. I'm not sure what the fallout of a zero button clutter event is within mutter and whether that will blow something else up.

For the new action mapper I started with duplicating the pad action mapper but then decided to implement a parent MetaTabletActionMapper for both. More boilerplate but overall a less duplicated approach and I can envision this maybe being used as a more generic action mapper for any buttons. I still consider myself a GObject newb so there's probably a few issues with the structure there.

backends/native: Apply stylus button mappings before anything else fixes a real bug: currently the stylus buttons are used as-is in clutter despite carrying a mapped button, e.g. mapping BTN_STYLUS to right-click only affects the behaviour in clients but not in gnome-shell where it remains the (default) middle button.

The new MetaToolActionMapper needs to read the settings which is... tricky. The button mapping happens when the Clutter event is generated. I'm not sure what black magic is required to get to the input settings but it turns out they're stored in the tool via a GQuark so right now I'm abusing that. Any hints on how to do this better would be appreciate.

Draft because this needs more testing, esp. in X11.

For testing:

$ STYLUS_SERIAL=99800b93
$ gsettings set org.gnome.desktop.peripherals.tablet.stylus:/org/gnome/desktop/peripherals/stylus/$STYLUS_SERIAL/ button-action keybinding
$ gsettings set org.gnome.desktop.peripherals.tablet.stylus:/org/gnome/desktop/peripherals/stylus/$STYLUS_SERIAL/ button-keybinding '<Control><Alt>t'
$ gsettings set org.gnome.desktop.peripherals.tablet.stylus:/org/gnome/desktop/peripherals/stylus/$STYLUS_SERIAL/ secondary-button-action switch-monitor

cc @carlosg, @Joshua-Dickens

Edited by Peter Hutterer

Merge request reports