wl_backend: restore cursor reset on enter/leave with grab guard — fixes stuck cursor

This commit is contained in:
Ollie 2026-05-29 17:12:39 +02:00
parent 1fed9a1a3e
commit fd7a760ce3
1 changed files with 9 additions and 6 deletions

View File

@ -6432,13 +6432,15 @@ wl_update_pointer_focus(uint32_t time_msec)
wl_state.pointer_x, wl_state.pointer_y, &sx, &sy, &view);
}
/* Track last focused surface for cursor reset on focus leave.
* We do NOT reset to left_ptr on enter — the client sets its own
* cursor via wl_pointer.set_cursor (handle_seat_request_cursor). */
static struct wlr_surface *last_focused_surface = NULL;
if (surface) {
if (surface != last_focused_surface) {
last_focused_surface = surface;
/* Set default cursor on new surface entry. The client will
* override via wl_pointer.set_cursor, but if we're in a grab
* (move/resize, DND) the grab system manages the cursor. */
if (!wl_state.grab_type)
wl_set_cursor_image("left_ptr");
}
wlr_seat_pointer_notify_enter(wl_state.seat, surface, sx, sy);
wlr_seat_pointer_notify_motion(wl_state.seat, time_msec, sx, sy);
@ -6448,9 +6450,10 @@ wl_update_pointer_focus(uint32_t time_msec)
last_focused_surface = NULL;
}
wlr_seat_pointer_clear_focus(wl_state.seat);
/* When pointer leaves all surfaces, leave the last cursor in
* place. The next pointer enter will let the client set its own
* cursor, or the grab system manages cursor explicitly. */
/* Restore WM cursor when pointer leaves all surfaces.
* Don't reset during grabs — pointer_change_grab manages that. */
if (!wl_state.grab_type)
wl_set_cursor_image("left_ptr");
}
/* Phase 29 (FFP): focus-follows-pointer — when the pointer enters a new
* managed view, deliver WM keyboard focus without raising.