Add a separate per-view shortcuts_inhibitor command that can be used with criteria to override the per-seat defaults. This allows to e.g. disable shortcuts inhibiting globally but enable it for specific, known-good virtualization and remote desktop software or, alternatively, to blacklist that one slightly broken piece of software that just doesn't seem to get it right but insists on trying. Add a flag to sway_view and handling logic in the input manager that respects that flag if configured but falls back to per-seat config otherwise. Add the actual command but with just enable and disable subcommands since there's no value in duplicating the per-seat activate/deactivate/toggle logic here. Split the inhibitor retrieval helper in two so we can use the backend half in the command to retrieve inhibitors for a specific surface and not just the currently focused one. Extend the manual page with documentation of the command and references to its per-seat sibling and usefulness with criteria. Signed-off-by: Michael Weiser <michael.weiser@gmx.de>master
parent
2473cac32c
commit
0f11aa037a
@ -0,0 +1,49 @@
|
||||
#include <string.h>
|
||||
#include "log.h"
|
||||
#include "sway/commands.h"
|
||||
#include "sway/config.h"
|
||||
#include "sway/input/seat.h"
|
||||
#include "sway/tree/container.h"
|
||||
#include "sway/tree/view.h"
|
||||
|
||||
struct cmd_results *cmd_shortcuts_inhibitor(int argc, char **argv) {
|
||||
struct cmd_results *error = NULL;
|
||||
if ((error = checkarg(argc, "shortcuts_inhibitor", EXPECTED_EQUAL_TO, 1))) {
|
||||
return error;
|
||||
}
|
||||
|
||||
struct sway_container *con = config->handler_context.container;
|
||||
if (!con || !con->view) {
|
||||
return cmd_results_new(CMD_INVALID,
|
||||
"Only views can have shortcuts inhibitors");
|
||||
}
|
||||
|
||||
struct sway_view *view = con->view;
|
||||
if (strcmp(argv[0], "enable") == 0) {
|
||||
view->shortcuts_inhibit = SHORTCUTS_INHIBIT_ENABLE;
|
||||
} else if (strcmp(argv[0], "disable") == 0) {
|
||||
view->shortcuts_inhibit = SHORTCUTS_INHIBIT_DISABLE;
|
||||
|
||||
struct sway_seat *seat = NULL;
|
||||
wl_list_for_each(seat, &server.input->seats, link) {
|
||||
struct sway_keyboard_shortcuts_inhibitor *sway_inhibitor =
|
||||
keyboard_shortcuts_inhibitor_get_for_surface(
|
||||
seat, view->surface);
|
||||
if (!sway_inhibitor) {
|
||||
continue;
|
||||
}
|
||||
|
||||
wlr_keyboard_shortcuts_inhibitor_v1_deactivate(
|
||||
sway_inhibitor->inhibitor);
|
||||
sway_log(SWAY_DEBUG, "Deactivated keyboard shortcuts "
|
||||
"inhibitor for seat %s on view",
|
||||
seat->wlr_seat->name);
|
||||
|
||||
}
|
||||
} else {
|
||||
return cmd_results_new(CMD_INVALID,
|
||||
"Expected `shortcuts_inhibitor enable|disable`");
|
||||
}
|
||||
|
||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||
}
|
Loading…
Reference in new issue