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 | 4537c8b3d432a5f5afb5669666ec2a40a18a2a0c (diff) | |
download | sway-c150177a94e1b3df3710d1b2b3db1d59fb396685.tar.xz |
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 @@ #include "sway/input/cursor.h" #include "sway/input/seat.h" #include "sway/input/tablet.h" +#include "sway/output.h" #include "sway/tree/view.h" +#include "sway/tree/workspace.h" #include "log.h" #if HAVE_XWAYLAND #include "sway/xwayland.h" @@ -513,6 +515,22 @@ static void check_focus_follows_mouse(struct sway_seat *seat, struct seatop_default_event *e, struct sway_node *hovered_node) { struct sway_node *focus = seat_get_focus(seat); + // This is the case if a layer-shell surface is hovered. + // If it's on another output, focus the active workspace there. + if (!hovered_node) { + struct wlr_output *wlr_output = wlr_output_layout_output_at( + root->output_layout, seat->cursor->cursor->x, seat->cursor->cursor->y); + if (wlr_output == NULL) { + return; + } + struct sway_output *hovered_output = wlr_output->data; + if (focus && hovered_output != node_get_output(focus)) { + struct sway_workspace *ws = output_get_active_workspace(hovered_output); + seat_set_focus(seat, &ws->node); + } + return; + } + // If a workspace node is hovered (eg. in the gap area), only set focus if // the workspace is on a different output to the previous focus. if (focus && hovered_node->type == N_WORKSPACE) { @@ -549,7 +567,7 @@ static void handle_pointer_motion(struct sway_seat *seat, uint32_t time_msec, struct sway_node *node = node_at_coords(seat, cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); - if (node && config->focus_follows_mouse != FOLLOWS_NO) { + if (config->focus_follows_mouse != FOLLOWS_NO) { check_focus_follows_mouse(seat, e, node); } @@ -583,7 +601,7 @@ static void handle_tablet_tool_motion(struct sway_seat *seat, struct sway_node *node = node_at_coords(seat, cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); - if (node && config->focus_follows_mouse != FOLLOWS_NO) { + if (config->focus_follows_mouse != FOLLOWS_NO) { check_focus_follows_mouse(seat, e, node); } |