diff options
author | David96 <david@hameipe.de> | 2020-09-13 19:11:08 +0200 |
---|---|---|
committer | Tudor Brindus <me@tbrindus.ca> | 2020-09-26 17:42:14 -0400 |
commit | c150177a94e1b3df3710d1b2b3db1d59fb396685 (patch) | |
tree | d471bfa0c847b03ebbbad8a89a9f726fda004d5d /sway | |
parent | check parent surface before it is destroyed (diff) | |
download | sway-c150177a94e1b3df3710d1b2b3db1d59fb396685.tar.gz sway-c150177a94e1b3df3710d1b2b3db1d59fb396685.tar.zst sway-c150177a94e1b3df3710d1b2b3db1d59fb396685.zip |
Make focus_follows_mouse work when hovering a layer-shell surface on another output
Fixes #5668
Diffstat (limited to 'sway')
-rw-r--r-- | sway/input/seatop_default.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c index 55c9159a..ae593f5c 100644 --- a/sway/input/seatop_default.c +++ b/sway/input/seatop_default.c | |||
@@ -7,7 +7,9 @@ | |||
7 | #include "sway/input/cursor.h" | 7 | #include "sway/input/cursor.h" |
8 | #include "sway/input/seat.h" | 8 | #include "sway/input/seat.h" |
9 | #include "sway/input/tablet.h" | 9 | #include "sway/input/tablet.h" |
10 | #include "sway/output.h" | ||
10 | #include "sway/tree/view.h" | 11 | #include "sway/tree/view.h" |
12 | #include "sway/tree/workspace.h" | ||
11 | #include "log.h" | 13 | #include "log.h" |
12 | #if HAVE_XWAYLAND | 14 | #if HAVE_XWAYLAND |
13 | #include "sway/xwayland.h" | 15 | #include "sway/xwayland.h" |
@@ -513,6 +515,22 @@ static void check_focus_follows_mouse(struct sway_seat *seat, | |||
513 | struct seatop_default_event *e, struct sway_node *hovered_node) { | 515 | struct seatop_default_event *e, struct sway_node *hovered_node) { |
514 | struct sway_node *focus = seat_get_focus(seat); | 516 | struct sway_node *focus = seat_get_focus(seat); |
515 | 517 | ||
518 | // This is the case if a layer-shell surface is hovered. | ||
519 | // If it's on another output, focus the active workspace there. | ||
520 | if (!hovered_node) { | ||
521 | struct wlr_output *wlr_output = wlr_output_layout_output_at( | ||
522 | root->output_layout, seat->cursor->cursor->x, seat->cursor->cursor->y); | ||
523 | if (wlr_output == NULL) { | ||
524 | return; | ||
525 | } | ||
526 | struct sway_output *hovered_output = wlr_output->data; | ||
527 | if (focus && hovered_output != node_get_output(focus)) { | ||
528 | struct sway_workspace *ws = output_get_active_workspace(hovered_output); | ||
529 | seat_set_focus(seat, &ws->node); | ||
530 | } | ||
531 | return; | ||
532 | } | ||
533 | |||
516 | // If a workspace node is hovered (eg. in the gap area), only set focus if | 534 | // If a workspace node is hovered (eg. in the gap area), only set focus if |
517 | // the workspace is on a different output to the previous focus. | 535 | // the workspace is on a different output to the previous focus. |
518 | if (focus && hovered_node->type == N_WORKSPACE) { | 536 | if (focus && hovered_node->type == N_WORKSPACE) { |
@@ -549,7 +567,7 @@ static void handle_pointer_motion(struct sway_seat *seat, uint32_t time_msec, | |||
549 | struct sway_node *node = node_at_coords(seat, | 567 | struct sway_node *node = node_at_coords(seat, |
550 | cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); | 568 | cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); |
551 | 569 | ||
552 | if (node && config->focus_follows_mouse != FOLLOWS_NO) { | 570 | if (config->focus_follows_mouse != FOLLOWS_NO) { |
553 | check_focus_follows_mouse(seat, e, node); | 571 | check_focus_follows_mouse(seat, e, node); |
554 | } | 572 | } |
555 | 573 | ||
@@ -583,7 +601,7 @@ static void handle_tablet_tool_motion(struct sway_seat *seat, | |||
583 | struct sway_node *node = node_at_coords(seat, | 601 | struct sway_node *node = node_at_coords(seat, |
584 | cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); | 602 | cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); |
585 | 603 | ||
586 | if (node && config->focus_follows_mouse != FOLLOWS_NO) { | 604 | if (config->focus_follows_mouse != FOLLOWS_NO) { |
587 | check_focus_follows_mouse(seat, e, node); | 605 | check_focus_follows_mouse(seat, e, node); |
588 | } | 606 | } |
589 | 607 | ||