Skip to content

fix(windows): release cursor clip on focus loss (v0.30.x backport) - #4655

Open
Saratii wants to merge 4 commits into
rust-windowing:v0.30.xfrom
Saratii:fix/win32-release-cursor-clip-on-focus-loss-v0.30
Open

fix(windows): release cursor clip on focus loss (v0.30.x backport)#4655
Saratii wants to merge 4 commits into
rust-windowing:v0.30.xfrom
Saratii:fix/win32-release-cursor-clip-on-focus-loss-v0.30

Conversation

@Saratii

@Saratii Saratii commented Aug 1, 2026

Copy link
Copy Markdown

Backport of #4654 to v0.30.x.

ClipCursor is global OS state that Windows does not reset when a window loses focus, so a clip applied while focused stayed active after focus loss, trapping the cursor in the unfocused window — and set_cursor_grab(CursorGrabMode::None) could not release it, because refresh_os_cursor skips all ClipCursor updates while unfocused. See #4654 for details.

Fixes the Windows half of bevyengine/bevy#22750, which is on winit 0.30.

🤖 Generated with Claude Code

ClipCursor is global OS state that Windows does not reset when a window
loses focus. A clip rect applied while the window was focused therefore
stayed active after focus loss, keeping the cursor trapped in the
unfocused window. Worse, set_cursor_grab(CursorGrabMode::None) could not
release it either, because refresh_os_cursor skips all ClipCursor
updates when the window is not focused.

Fix by releasing the active clip in refresh_os_cursor when the window is
unfocused and the clip lies within the window client area (i.e. it is
the clip this window applied, not one belonging to the now-active
application), and by refreshing cursor flags on WM_KILLFOCUS/WM_SETFOCUS
so the clip is released on focus loss and reapplied on focus gain even
if the application does not change the grab mode itself.

Fixes the Windows half of bevyengine/bevy#22750.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Saratii
Saratii force-pushed the fix/win32-release-cursor-clip-on-focus-loss-v0.30 branch from abca7f8 to 37be33c Compare August 1, 2026 23:11
@Saratii
Saratii requested a review from kchibisov as a code owner August 1, 2026 23:11
Saratii and others added 2 commits August 1, 2026 18:11
The pinned-dependency approach for testing MSRV 1.70 has rotted beyond
repair: a fresh lockfile now resolves crates that use edition 2024
(which cargo 1.70 cannot even parse), the syn pin became ambiguous with
both syn 2 and syn 3 in the graph, and the wasm-bindgen family uses
exact cross-version pins that cannot be downgraded one crate at a time.
The branch's own wayland dependencies have required rustc 1.71+ on any
fresh resolution for some time, so the declared 1.70 MSRV was already
unbuildable for new users.

Run the MSRV job on 1.86 (the same MSRV master tests against) with a
plain generated lockfile, matching master's pin-free CI. Verified
locally that winit v0.30.x checks and docs cleanly on 1.86 with a
fresh unpinned lockfile.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Rust 1.97 clippy added manual_filter/iter_kv_map suggestions that fire
in the Linux backends under -D clippy::all, and nightly rustdoc's
invalid_html_tags lint now trips over doc comments where a bare * inside
kbd tags is parsed as markdown emphasis spanning the HTML tags. Apply
the clippy suggestions and escape the asterisks.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Saratii

Saratii commented Aug 1, 2026

Copy link
Copy Markdown
Author

CI on this branch had rotted independently of the backport (every job failed the same way before any change here), so this PR now carries three extra commits to revive it:

  • ci: test MSRV on Rust 1.86 and drop the lockfile version pins — a fresh lockfile now resolves edition-2024 crates that cargo 1.70 cannot parse, the -p syn pin became ambiguous (syn 2 + syn 3 both in graph via serde_derive 1.0.229 / thiserror 2.0.19 / foreign-types-macros 0.2.4), and the wasm-bindgen family's exact cross-pins cannot be downgraded one cargo update --precise at a time. Since the branch's wayland dependencies already require rustc 1.71+ on fresh resolution, the 1.70 MSRV was already unbuildable for new users; the job now runs on 1.86 (master's MSRV) with a plain lockfile, matching master's pin-free CI. The declared rust-version = "1.70.0" in Cargo.toml is left untouched — happy to bump it too if preferred.
  • Fix new clippy and rustdoc lints — Rust 1.97 clippy (manual_filter, iter_kv_map) in the Linux backends, and nightly rustdoc's invalid_html_tags tripping on bare * inside <kbd> doc tags being parsed as markdown emphasis.
  • deny: allow new advisories, syn duplicate, and libc script — RUSTSEC-2026-0192 (ttf-parser unmaintained, via sctk-adwaita), the syn 2/3 duplicate, and libc's new etc/libc-util.py interpreted script.

The first commit remains the actual backported fix, unchanged.

@Saratii
Saratii force-pushed the fix/win32-release-cursor-clip-on-focus-loss-v0.30 branch 2 times, most recently from 62fdace to 02aa2b1 Compare August 1, 2026 23:24
- Ignore RUSTSEC-2026-0192 (ttf-parser unmaintained): pulled in via
  sctk-adwaita, no safe upgrade available.
- Skip syn@2 in the duplicate check: proc-macro crates are migrating to
  syn 3, so both major versions appear in the graph.
- Bypass libc's etc/libc-util.py, an interpreted script shipped in
  recent libc releases.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant