aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/shortcuts_inhibitor.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/shortcuts_inhibitor.c')
-rw-r--r--sway/commands/shortcuts_inhibitor.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/sway/commands/shortcuts_inhibitor.c b/sway/commands/shortcuts_inhibitor.c
new file mode 100644
index 00000000..ffa1a5c9
--- /dev/null
+++ b/sway/commands/shortcuts_inhibitor.c
@@ -0,0 +1,49 @@
1#include <string.h>
2#include "log.h"
3#include "sway/commands.h"
4#include "sway/config.h"
5#include "sway/input/seat.h"
6#include "sway/tree/container.h"
7#include "sway/tree/view.h"
8
9struct cmd_results *cmd_shortcuts_inhibitor(int argc, char **argv) {
10 struct cmd_results *error = NULL;
11 if ((error = checkarg(argc, "shortcuts_inhibitor", EXPECTED_EQUAL_TO, 1))) {
12 return error;
13 }
14
15 struct sway_container *con = config->handler_context.container;
16 if (!con || !con->view) {
17 return cmd_results_new(CMD_INVALID,
18 "Only views can have shortcuts inhibitors");
19 }
20
21 struct sway_view *view = con->view;
22 if (strcmp(argv[0], "enable") == 0) {
23 view->shortcuts_inhibit = SHORTCUTS_INHIBIT_ENABLE;
24 } else if (strcmp(argv[0], "disable") == 0) {
25 view->shortcuts_inhibit = SHORTCUTS_INHIBIT_DISABLE;
26
27 struct sway_seat *seat = NULL;
28 wl_list_for_each(seat, &server.input->seats, link) {
29 struct sway_keyboard_shortcuts_inhibitor *sway_inhibitor =
30 keyboard_shortcuts_inhibitor_get_for_surface(
31 seat, view->surface);
32 if (!sway_inhibitor) {
33 continue;
34 }
35
36 wlr_keyboard_shortcuts_inhibitor_v1_deactivate(
37 sway_inhibitor->inhibitor);
38 sway_log(SWAY_DEBUG, "Deactivated keyboard shortcuts "
39 "inhibitor for seat %s on view",
40 seat->wlr_seat->name);
41
42 }
43 } else {
44 return cmd_results_new(CMD_INVALID,
45 "Expected `shortcuts_inhibitor enable|disable`");
46 }
47
48 return cmd_results_new(CMD_SUCCESS, NULL);
49}