diff options
Diffstat (limited to 'sway/commands/sticky.c')
-rw-r--r-- | sway/commands/sticky.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/sway/commands/sticky.c b/sway/commands/sticky.c new file mode 100644 index 00000000..4bb4bd39 --- /dev/null +++ b/sway/commands/sticky.c | |||
@@ -0,0 +1,40 @@ | |||
1 | #include <string.h> | ||
2 | #include <strings.h> | ||
3 | #include "sway/commands.h" | ||
4 | #include "sway/input/seat.h" | ||
5 | #include "sway/ipc-server.h" | ||
6 | #include "sway/output.h" | ||
7 | #include "sway/tree/arrange.h" | ||
8 | #include "sway/tree/container.h" | ||
9 | #include "sway/tree/layout.h" | ||
10 | #include "sway/tree/view.h" | ||
11 | #include "list.h" | ||
12 | |||
13 | struct cmd_results *cmd_sticky(int argc, char **argv) { | ||
14 | struct cmd_results *error = NULL; | ||
15 | if ((error = checkarg(argc, "sticky", EXPECTED_EQUAL_TO, 1))) { | ||
16 | return error; | ||
17 | } | ||
18 | struct sway_container *container = | ||
19 | config->handler_context.current_container; | ||
20 | if (!container->is_floating) { | ||
21 | return cmd_results_new(CMD_FAILURE, "sticky", | ||
22 | "Can't set sticky on a tiled container"); | ||
23 | } | ||
24 | |||
25 | bool wants_sticky; | ||
26 | if (strcasecmp(argv[0], "enable") == 0) { | ||
27 | wants_sticky = true; | ||
28 | } else if (strcasecmp(argv[0], "disable") == 0) { | ||
29 | wants_sticky = false; | ||
30 | } else if (strcasecmp(argv[0], "toggle") == 0) { | ||
31 | wants_sticky = !container->is_sticky; | ||
32 | } else { | ||
33 | return cmd_results_new(CMD_FAILURE, "sticky", | ||
34 | "Expected 'sticky <enable|disable|toggle>'"); | ||
35 | } | ||
36 | |||
37 | container->is_sticky = wants_sticky; | ||
38 | |||
39 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
40 | } | ||