diff options
-rw-r--r-- | include/sway/config.h | 8 | ||||
-rw-r--r-- | sway/commands/focus_follows_mouse.c | 11 | ||||
-rw-r--r-- | sway/config.c | 2 | ||||
-rw-r--r-- | sway/input/cursor.c | 8 |
4 files changed, 22 insertions, 7 deletions
diff --git a/include/sway/config.h b/include/sway/config.h index 852d5576..0912bc73 100644 --- a/include/sway/config.h +++ b/include/sway/config.h | |||
@@ -327,6 +327,12 @@ struct ipc_policy { | |||
327 | uint32_t features; | 327 | uint32_t features; |
328 | }; | 328 | }; |
329 | 329 | ||
330 | enum focus_follows_mouse_mode { | ||
331 | FOLLOWS_NO, | ||
332 | FOLLOWS_YES, | ||
333 | FOLLOWS_ALWAYS | ||
334 | }; | ||
335 | |||
330 | enum focus_wrapping_mode { | 336 | enum focus_wrapping_mode { |
331 | WRAP_NO, | 337 | WRAP_NO, |
332 | WRAP_YES, | 338 | WRAP_YES, |
@@ -378,7 +384,7 @@ struct sway_config { | |||
378 | enum sway_popup_during_fullscreen popup_during_fullscreen; | 384 | enum sway_popup_during_fullscreen popup_during_fullscreen; |
379 | 385 | ||
380 | // Flags | 386 | // Flags |
381 | bool focus_follows_mouse; | 387 | enum focus_follows_mouse_mode focus_follows_mouse; |
382 | enum mouse_warping_mode mouse_warping; | 388 | enum mouse_warping_mode mouse_warping; |
383 | enum focus_wrapping_mode focus_wrapping; | 389 | enum focus_wrapping_mode focus_wrapping; |
384 | bool active; | 390 | bool active; |
diff --git a/sway/commands/focus_follows_mouse.c b/sway/commands/focus_follows_mouse.c index 0b0e334c..d0d2cb8a 100644 --- a/sway/commands/focus_follows_mouse.c +++ b/sway/commands/focus_follows_mouse.c | |||
@@ -7,8 +7,15 @@ struct cmd_results *cmd_focus_follows_mouse(int argc, char **argv) { | |||
7 | struct cmd_results *error = NULL; | 7 | struct cmd_results *error = NULL; |
8 | if ((error = checkarg(argc, "focus_follows_mouse", EXPECTED_EQUAL_TO, 1))) { | 8 | if ((error = checkarg(argc, "focus_follows_mouse", EXPECTED_EQUAL_TO, 1))) { |
9 | return error; | 9 | return error; |
10 | } else if(strcmp(argv[0], "no") == 0) { | ||
11 | config->focus_follows_mouse = FOLLOWS_NO; | ||
12 | } else if(strcmp(argv[0], "yes") == 0) { | ||
13 | config->focus_follows_mouse = FOLLOWS_YES; | ||
14 | } else if(strcmp(argv[0], "always") == 0) { | ||
15 | config->focus_follows_mouse = FOLLOWS_ALWAYS; | ||
16 | } else { | ||
17 | return cmd_results_new(CMD_FAILURE, "focus_follows_mouse", | ||
18 | "Expected 'focus_follows_mouse no|yes|always'"); | ||
10 | } | 19 | } |
11 | config->focus_follows_mouse = | ||
12 | parse_boolean(argv[0], config->focus_follows_mouse); | ||
13 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 20 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
14 | } | 21 | } |
diff --git a/sway/config.c b/sway/config.c index 7ef3ef38..64653024 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -220,7 +220,7 @@ static void config_defaults(struct sway_config *config) { | |||
220 | config->floating_minimum_height = 50; | 220 | config->floating_minimum_height = 50; |
221 | 221 | ||
222 | // Flags | 222 | // Flags |
223 | config->focus_follows_mouse = true; | 223 | config->focus_follows_mouse = FOLLOWS_YES; |
224 | config->mouse_warping = WARP_OUTPUT; | 224 | config->mouse_warping = WARP_OUTPUT; |
225 | config->focus_wrapping = WRAP_YES; | 225 | config->focus_wrapping = WRAP_YES; |
226 | config->validating = false; | 226 | config->validating = false; |
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index c539df40..62cdba37 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -637,7 +637,8 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, | |||
637 | cursor->previous.y = cursor->cursor->y; | 637 | cursor->previous.y = cursor->cursor->y; |
638 | cursor->previous.node = node; | 638 | cursor->previous.node = node; |
639 | 639 | ||
640 | if (node && config->focus_follows_mouse) { | 640 | if (node && (config->focus_follows_mouse == FOLLOWS_YES || |
641 | config->focus_follows_mouse == FOLLOWS_ALWAYS)) { | ||
641 | struct sway_node *focus = seat_get_focus(seat); | 642 | struct sway_node *focus = seat_get_focus(seat); |
642 | if (focus && node->type == N_WORKSPACE) { | 643 | if (focus && node->type == N_WORKSPACE) { |
643 | // Only follow the mouse if it would move to a new output | 644 | // Only follow the mouse if it would move to a new output |
@@ -652,9 +653,10 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, | |||
652 | // - cursor is over a new view, i.e. entered a new window; and | 653 | // - cursor is over a new view, i.e. entered a new window; and |
653 | // - the new view is visible, i.e. not hidden in a stack or tab; and | 654 | // - the new view is visible, i.e. not hidden in a stack or tab; and |
654 | // - the seat does not have a keyboard grab | 655 | // - the seat does not have a keyboard grab |
655 | if (!wlr_seat_keyboard_has_grab(cursor->seat->wlr_seat) && | 656 | if ((!wlr_seat_keyboard_has_grab(cursor->seat->wlr_seat) && |
656 | node != prev_node && | 657 | node != prev_node && |
657 | view_is_visible(node->sway_container->view)) { | 658 | view_is_visible(node->sway_container->view)) || |
659 | config->focus_follows_mouse == FOLLOWS_ALWAYS) { | ||
658 | seat_set_focus(seat, node); | 660 | seat_set_focus(seat, node); |
659 | } else { | 661 | } else { |
660 | struct sway_node *next_focus = | 662 | struct sway_node *next_focus = |