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

@ -476,10 +476,12 @@ void xdg_shell_finish(struct server *server);
void desktop_focus_view(struct view *view, bool raise);
/**
* desktop_focus_view_or_surface() - like desktop_focus_view() but can
* also focus other (e.g. xwayland-unmanaged) surfaces
* desktop_focus_for_cursor_update() - like desktop_focus_view() but can
* also focus other (e.g. xwayland-unmanaged) surfaces.
*
* Used only for cursor-driven focus updates.
*/
void desktop_focus_view_or_surface(struct seat *seat, struct view *view,
void desktop_focus_for_cursor_update(struct seat *seat, struct view *view,
struct wlr_surface *surface, bool raise);
void desktop_arrange_all_views(struct server *server);