commands: Add shortcuts_inhibitor command

Add a command to influence keyboard shortcuts inhibitors. In its current
form it can be used to activate, deactivate or toggle an existing
inhibitor on the surface currently receiving input. This can be used to
define an escape shortcut such as:

bindsym --inhibited $mod+Escape seat - shortcuts_inhibitor deactivate

It also allows the user to configure a per-seat default of whether
keyboard inhibitors are honoured by default (the default) or not. Using
the activate/toggle command they can then enable the lingering inhibitor
at a later time of their choosing.

As a side effect this allows to specifically address a named seat for
actions as well, whatever use-case that might serve.

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
This commit is contained in:
Michael Weiser 2020-02-16 00:40:18 +01:00 committed by Brian Ashworth
parent eeac0aa170
commit 3ee5aace33
8 changed files with 150 additions and 0 deletions

View file

@ -333,6 +333,26 @@ static void handle_keyboard_shortcuts_inhibit_new_inhibitor(
struct sway_seat *seat = inhibitor->seat->data;
wl_list_insert(&seat->keyboard_shortcuts_inhibitors, &sway_inhibitor->link);
struct seat_config *config = seat_get_config(seat);
if (!config) {
config = seat_get_config_by_name("*");
}
if (config && config->shortcuts_inhibit == SHORTCUTS_INHIBIT_DISABLE) {
/**
* Here we deny to honour the inhibitor by never sending the
* activate signal. We can not, however, destroy the inhibitor
* because the protocol doesn't allow for it. So it will linger
* until the client removes it im- or explicitly. But at least
* it can only be one inhibitor per surface and seat at a time.
*
* We also want to allow the user to activate the inhibitor
* manually later which is why we do this check here where the
* inhibitor is already attached to its seat and ready for use.
*/
return;
}
wlr_keyboard_shortcuts_inhibitor_v1_activate(inhibitor);
}