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