desktop: enforce followMouse focus policy more strictly

With followMouse=yes in the config, a client activation request was
still allowed to focus a view that wasn't under the mouse cursor, but
it would then be immediately unfocused again. With some clients using
modal dialogs (e.g. Scribus), this could lead to an infinite cycle of
the client and labwc continually switching the focus back and forth.

To break the cycle, only allow focusing a view under the cursor when
when followMouse=yes.

v2: allow focusing a new/raised view appearing under the cursor
v3: allow focusing a sub-view/sibling of the requested view
v4: fix new xdg-shell views under mouse not being focused

Fixes: #2722
This commit is contained in:
John Lindgren 2025-06-12 10:55:56 -04:00
parent 5a50a02ba3
commit 34892c35be
6 changed files with 66 additions and 30 deletions

View file

@ -629,7 +629,7 @@ cursor_process_motion(struct server *server, uint32_t time, double *sx, double *
* If followMouse=yes, update the keyboard focus when the
* cursor enters a surface
*/
desktop_focus_view_or_surface(seat,
desktop_focus_for_cursor_update(seat,
view_from_wlr_surface(new_focused_surface),
new_focused_surface, rc.raise_on_focus);
}
@ -649,7 +649,7 @@ _cursor_update_focus(struct server *server)
* Always focus the surface below the cursor when
* followMouse=yes and followMouseRequiresMovement=no.
*/
desktop_focus_view_or_surface(&server->seat, ctx.view,
desktop_focus_for_cursor_update(&server->seat, ctx.view,
ctx.surface, rc.raise_on_focus);
}
@ -1092,7 +1092,7 @@ cursor_process_button_press(struct seat *seat, uint32_t button, uint32_t time_ms
}
#ifdef HAVE_XWAYLAND
} else if (ctx.type == LAB_SSD_UNMANAGED) {
desktop_focus_view_or_surface(seat, NULL, ctx.surface,
desktop_focus_for_cursor_update(seat, NULL, ctx.surface,
/*raise*/ false);
#endif
}