diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-05-19 19:57:10 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2018-05-20 14:46:29 -0400 |
commit | a3d3c819cf38d7a04f79f6d5b16e11ac0a786135 (patch) | |
tree | c654c796330c5b330afe11a60a5acf2b1844f0fb | |
parent | 1afbfc94f4efb2ec6b021c224b6f432c625970e8 (diff) |
Fix focus_follows_mouse over swaybar
If you moved your mouse over swaybar (e.g. to scroll between
workspaces), focus would move to the workspace. This is not the right
thing to do. The solution is complicated by the fact that if you move
your mouse into a new output with an empty workspace, that workspace
_should_ receive focus.
-rw-r--r-- | sway/input/cursor.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 9259c475..3a73954c 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -146,7 +146,23 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec) struct sway_container *c = container_at_coords(cursor->seat, cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); if (c && config->focus_follows_mouse) { - seat_set_focus_warp(cursor->seat, c, false); + if (c->type == C_WORKSPACE) { + // Only follow the mouse if it would move to a new output + // Otherwise we'll focus the workspace, which is probably wrong + struct sway_container *focus = seat_get_focus(cursor->seat); + if (focus->type != C_OUTPUT) { + focus = container_parent(focus, C_OUTPUT); + } + struct sway_container *output = c; + if (output->type != C_OUTPUT) { + output = container_parent(c, C_OUTPUT); + } + if (output != focus) { + seat_set_focus_warp(cursor->seat, c, false); + } + } else { + seat_set_focus_warp(cursor->seat, c, false); + } } // reset cursor if switching between clients |