diff options
-rw-r--r-- | include/sway/config.h | 1 | ||||
-rw-r--r-- | sway/commands/floating_modifier.c | 12 | ||||
-rw-r--r-- | sway/config.c | 1 | ||||
-rw-r--r-- | sway/input/cursor.c | 8 |
4 files changed, 18 insertions, 4 deletions
diff --git a/include/sway/config.h b/include/sway/config.h index 032f4196..4a6bb780 100644 --- a/include/sway/config.h +++ b/include/sway/config.h | |||
@@ -320,6 +320,7 @@ struct sway_config { | |||
320 | struct bar_config *current_bar; | 320 | struct bar_config *current_bar; |
321 | char *swaybg_command; | 321 | char *swaybg_command; |
322 | uint32_t floating_mod; | 322 | uint32_t floating_mod; |
323 | bool floating_mod_inverse; | ||
323 | uint32_t dragging_key; | 324 | uint32_t dragging_key; |
324 | uint32_t resizing_key; | 325 | uint32_t resizing_key; |
325 | char *floating_scroll_up_cmd; | 326 | char *floating_scroll_up_cmd; |
diff --git a/sway/commands/floating_modifier.c b/sway/commands/floating_modifier.c index 9432c9f1..f5d2b3fe 100644 --- a/sway/commands/floating_modifier.c +++ b/sway/commands/floating_modifier.c | |||
@@ -1,10 +1,11 @@ | |||
1 | #include "strings.h" | ||
1 | #include "sway/commands.h" | 2 | #include "sway/commands.h" |
2 | #include "sway/config.h" | 3 | #include "sway/config.h" |
3 | #include "util.h" | 4 | #include "util.h" |
4 | 5 | ||
5 | struct cmd_results *cmd_floating_modifier(int argc, char **argv) { | 6 | struct cmd_results *cmd_floating_modifier(int argc, char **argv) { |
6 | struct cmd_results *error = NULL; | 7 | struct cmd_results *error = NULL; |
7 | if ((error = checkarg(argc, "floating_modifier", EXPECTED_EQUAL_TO, 1))) { | 8 | if ((error = checkarg(argc, "floating_modifier", EXPECTED_AT_LEAST, 1))) { |
8 | return error; | 9 | return error; |
9 | } | 10 | } |
10 | 11 | ||
@@ -14,6 +15,15 @@ struct cmd_results *cmd_floating_modifier(int argc, char **argv) { | |||
14 | "Invalid modifier"); | 15 | "Invalid modifier"); |
15 | } | 16 | } |
16 | 17 | ||
18 | if (argc == 1 || strcasecmp(argv[1], "normal") == 0) { | ||
19 | config->floating_mod_inverse = false; | ||
20 | } else if (strcasecmp(argv[1], "inverse") == 0) { | ||
21 | config->floating_mod_inverse = true; | ||
22 | } else { | ||
23 | return cmd_results_new(CMD_INVALID, "floating_modifier", | ||
24 | "Usage: floating_modifier <mod> [inverse|normal]"); | ||
25 | } | ||
26 | |||
17 | config->floating_mod = mod; | 27 | config->floating_mod = mod; |
18 | 28 | ||
19 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 29 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
diff --git a/sway/config.c b/sway/config.c index 90dfb9a9..2afffab1 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -180,6 +180,7 @@ static void config_defaults(struct sway_config *config) { | |||
180 | list_add(config->modes, config->current_mode); | 180 | list_add(config->modes, config->current_mode); |
181 | 181 | ||
182 | config->floating_mod = 0; | 182 | config->floating_mod = 0; |
183 | config->floating_mod_inverse = false; | ||
183 | config->dragging_key = BTN_LEFT; | 184 | config->dragging_key = BTN_LEFT; |
184 | config->resizing_key = BTN_RIGHT; | 185 | config->resizing_key = BTN_RIGHT; |
185 | 186 | ||
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 27597640..9eb11de1 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -449,15 +449,17 @@ static void dispatch_cursor_button_floating(struct sway_cursor *cursor, | |||
449 | bool over_title = edge == WLR_EDGE_NONE && !surface; | 449 | bool over_title = edge == WLR_EDGE_NONE && !surface; |
450 | 450 | ||
451 | // Check for beginning move | 451 | // Check for beginning move |
452 | if (button == BTN_LEFT && state == WLR_BUTTON_PRESSED && | 452 | uint32_t btn_move = config->floating_mod_inverse ? BTN_RIGHT : BTN_LEFT; |
453 | if (button == btn_move && state == WLR_BUTTON_PRESSED && | ||
453 | (mod_pressed || over_title)) { | 454 | (mod_pressed || over_title)) { |
454 | seat_begin_move(seat, cont, BTN_LEFT); | 455 | seat_begin_move(seat, cont, btn_move); |
455 | return; | 456 | return; |
456 | } | 457 | } |
457 | 458 | ||
458 | // Check for beginning resize | 459 | // Check for beginning resize |
459 | bool resizing_via_border = button == BTN_LEFT && edge != WLR_EDGE_NONE; | 460 | bool resizing_via_border = button == BTN_LEFT && edge != WLR_EDGE_NONE; |
460 | bool resizing_via_mod = button == BTN_RIGHT && mod_pressed; | 461 | uint32_t btn_resize = config->floating_mod_inverse ? BTN_LEFT : BTN_RIGHT; |
462 | bool resizing_via_mod = button == btn_resize && mod_pressed; | ||
461 | if ((resizing_via_border || resizing_via_mod) && | 463 | if ((resizing_via_border || resizing_via_mod) && |
462 | state == WLR_BUTTON_PRESSED) { | 464 | state == WLR_BUTTON_PRESSED) { |
463 | if (edge == WLR_EDGE_NONE) { | 465 | if (edge == WLR_EDGE_NONE) { |