cursor: update focus on entering SSD if followMouse=yes

This fixes a known regression in 885919fc that cursor entering the
titlebar (and other SSD parts) doesn't update the keyboard focus even when
followMouse=yes.
This commit is contained in:
tokyo4j 2025-11-30 20:45:30 +09:00 committed by Hiroaki Yamamoto
parent 7fb060e88c
commit e4ebc30c90
2 changed files with 22 additions and 13 deletions

View file

@ -78,6 +78,9 @@ struct seat {
*/ */
struct cursor_context_saved pressed; struct cursor_context_saved pressed;
/* Cursor context of the last cursor motion */
struct cursor_context_saved last_cursor_ctx;
struct lab_set bound_buttons; struct lab_set bound_buttons;
struct { struct {

View file

@ -664,9 +664,6 @@ cursor_process_motion(struct server *server, uint32_t time, double *sx, double *
} }
} }
struct wlr_surface *old_focused_surface =
seat->seat->pointer_state.focused_surface;
/* /*
* Cursor context that is actually interacting with cursor and should * Cursor context that is actually interacting with cursor and should
* be notified to the client. E.g. it is cleared when menu is open, * be notified to the client. E.g. it is cleared when menu is open,
@ -675,19 +672,28 @@ cursor_process_motion(struct server *server, uint32_t time, double *sx, double *
struct cursor_context notified_ctx = {0}; struct cursor_context notified_ctx = {0};
cursor_update_common(server, &ctx, &notified_ctx); cursor_update_common(server, &ctx, &notified_ctx);
struct wlr_surface *new_focused_surface = if (rc.focus_follow_mouse) {
seat->seat->pointer_state.focused_surface;
if (rc.focus_follow_mouse && new_focused_surface
&& old_focused_surface != new_focused_surface) {
/* /*
* If followMouse=yes, update the keyboard focus when the * If followMouse=yes, entering a surface or view updates
* cursor enters a surface * keyboard focus. Note that moving the cursor between a
* surface and a SSD within the same view doesn't update
* keyboard focus, and that entering a surface/view doesn't
* update keyboard focus if implicit grab is active.
*/ */
desktop_focus_view_or_surface(seat, bool entering = false;
view_from_wlr_surface(new_focused_surface), if (notified_ctx.view) {
new_focused_surface, rc.raise_on_focus); entering = notified_ctx.view
!= seat->last_cursor_ctx.ctx.view;
} else if (notified_ctx.surface) {
entering = notified_ctx.surface
!= seat->last_cursor_ctx.ctx.surface;
}
if (entering) {
desktop_focus_view_or_surface(seat, notified_ctx.view,
notified_ctx.surface, rc.raise_on_focus);
}
} }
cursor_context_save(&seat->last_cursor_ctx, &notified_ctx);
*sx = notified_ctx.sx; *sx = notified_ctx.sx;
*sy = notified_ctx.sy; *sy = notified_ctx.sy;