diff options
Diffstat (limited to 'sway/old/commands/floating_mod.c')
-rw-r--r-- | sway/old/commands/floating_mod.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/sway/old/commands/floating_mod.c b/sway/old/commands/floating_mod.c new file mode 100644 index 00000000..b8e81ab9 --- /dev/null +++ b/sway/old/commands/floating_mod.c | |||
@@ -0,0 +1,42 @@ | |||
1 | #include <string.h> | ||
2 | #include <strings.h> | ||
3 | #include "sway/commands.h" | ||
4 | #include "sway/input_state.h" | ||
5 | #include "list.h" | ||
6 | #include "log.h" | ||
7 | #include "stringop.h" | ||
8 | #include "util.h" | ||
9 | |||
10 | struct cmd_results *cmd_floating_mod(int argc, char **argv) { | ||
11 | struct cmd_results *error = NULL; | ||
12 | if ((error = checkarg(argc, "floating_modifier", EXPECTED_AT_LEAST, 1))) { | ||
13 | return error; | ||
14 | } | ||
15 | int i; | ||
16 | list_t *split = split_string(argv[0], "+"); | ||
17 | config->floating_mod = 0; | ||
18 | |||
19 | // set modifier keys | ||
20 | for (i = 0; i < split->length; ++i) { | ||
21 | config->floating_mod |= get_modifier_mask_by_name(split->items[i]); | ||
22 | } | ||
23 | free_flat_list(split); | ||
24 | if (!config->floating_mod) { | ||
25 | error = cmd_results_new(CMD_INVALID, "floating_modifier", "Unknown keys %s", argv[0]); | ||
26 | return error; | ||
27 | } | ||
28 | |||
29 | if (argc >= 2) { | ||
30 | if (strcasecmp("inverse", argv[1]) == 0) { | ||
31 | config->dragging_key = M_RIGHT_CLICK; | ||
32 | config->resizing_key = M_LEFT_CLICK; | ||
33 | } else if (strcasecmp("normal", argv[1]) == 0) { | ||
34 | config->dragging_key = M_LEFT_CLICK; | ||
35 | config->resizing_key = M_RIGHT_CLICK; | ||
36 | } else { | ||
37 | error = cmd_results_new(CMD_INVALID, "floating_modifier", "Invalid definition %s", argv[1]); | ||
38 | return error; | ||
39 | } | ||
40 | } | ||
41 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
42 | } | ||