diff options
Diffstat (limited to 'sway/old/commands/sticky.c')
-rw-r--r-- | sway/old/commands/sticky.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/sway/old/commands/sticky.c b/sway/old/commands/sticky.c new file mode 100644 index 00000000..4899e061 --- /dev/null +++ b/sway/old/commands/sticky.c | |||
@@ -0,0 +1,25 @@ | |||
1 | #include <string.h> | ||
2 | #include "sway/commands.h" | ||
3 | #include "sway/focus.h" | ||
4 | |||
5 | struct cmd_results *cmd_sticky(int argc, char **argv) { | ||
6 | struct cmd_results *error = NULL; | ||
7 | if (config->reading) return cmd_results_new(CMD_FAILURE, "sticky", "Can't be used in config file."); | ||
8 | if (!config->active) return cmd_results_new(CMD_FAILURE, "sticky", "Can only be used when sway is running."); | ||
9 | if ((error = checkarg(argc, "sticky", EXPECTED_EQUAL_TO, 1))) { | ||
10 | return error; | ||
11 | } | ||
12 | char *action = argv[0]; | ||
13 | swayc_t *cont = get_focused_view(&root_container); | ||
14 | if (strcmp(action, "toggle") == 0) { | ||
15 | cont->sticky = !cont->sticky; | ||
16 | } else if (strcmp(action, "enable") == 0) { | ||
17 | cont->sticky = true; | ||
18 | } else if (strcmp(action, "disable") == 0) { | ||
19 | cont->sticky = false; | ||
20 | } else { | ||
21 | return cmd_results_new(CMD_FAILURE, "sticky", | ||
22 | "Expected 'sticky enable|disable|toggle'"); | ||
23 | } | ||
24 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
25 | } | ||