mirror of
https://github.com/swaywm/sway.git
synced 2026-06-13 14:33:19 -04:00
input/seatop_default: fix focus on layer surface output switch
When `focus_follows_mouse` is enabled and the cursor moves from one output to a layer surface (such as swaybar) on another output, Sway would previously focus the workspace node. This updates `check_focus_follows_mouse` to use `seat_get_focus_inactive`, ensuring that the previously focused window on that workspace receives focus instead. This change also updates `seat_get_focus_inactive` to return the requested node as a fallback if it exists in the focus stack but has no focused descendants. This handles the case of an empty workspace.
This commit is contained in:
parent
f1b40bc288
commit
20904977cf
2 changed files with 10 additions and 1 deletions
|
|
@ -1360,10 +1360,19 @@ struct sway_node *seat_get_focus_inactive(struct sway_seat *seat,
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
struct sway_seat_node *current;
|
struct sway_seat_node *current;
|
||||||
|
struct sway_node *fallback = NULL;
|
||||||
wl_list_for_each(current, &seat->focus_stack, link) {
|
wl_list_for_each(current, &seat->focus_stack, link) {
|
||||||
|
// prioritize a focused descendant
|
||||||
if (node_has_ancestor(current->node, node)) {
|
if (node_has_ancestor(current->node, node)) {
|
||||||
return current->node;
|
return current->node;
|
||||||
}
|
}
|
||||||
|
// if the node itself is in the focus stack, save it as a fallback
|
||||||
|
if (!fallback && current->node == node) {
|
||||||
|
fallback = current->node;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (fallback) {
|
||||||
|
return fallback;
|
||||||
}
|
}
|
||||||
if (node->type == N_WORKSPACE) {
|
if (node->type == N_WORKSPACE) {
|
||||||
return node;
|
return node;
|
||||||
|
|
|
||||||
|
|
@ -565,7 +565,7 @@ static void check_focus_follows_mouse(struct sway_seat *seat,
|
||||||
struct sway_output *hovered_output = wlr_output->data;
|
struct sway_output *hovered_output = wlr_output->data;
|
||||||
if (focus && hovered_output != node_get_output(focus)) {
|
if (focus && hovered_output != node_get_output(focus)) {
|
||||||
struct sway_workspace *ws = output_get_active_workspace(hovered_output);
|
struct sway_workspace *ws = output_get_active_workspace(hovered_output);
|
||||||
seat_set_focus(seat, &ws->node);
|
seat_set_focus(seat, seat_get_focus_inactive(seat, &ws->node));
|
||||||
transaction_commit_dirty();
|
transaction_commit_dirty();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue