[PR #614] [MERGED] Fix mouse capture after world loading #2678

Closed
opened 2026-11-02 15:58:10 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/614
Author: @LookImEcho-Rick
Created: 10/17/2026
Status: ✅ Merged
Merged: 10/17/2026
Merged by: @ludovic111

Base: main ← Head: codex/fix-world-input-capture


📝 Commits (2)

  • 3230b6b Fix mouse capture when world loading completes
  • cde0703 Merge main and preserve capture and mining release behavior

📊 Changes

3 files changed (+171 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+15 -0)
📝 crates/horizon-client/src/game/remote.rs (+1 -0)
➕ tests/test_world_input_capture.py (+155 -0)

📄 Description

What and why

Fixes #612.

Entering a world could leave Horizon active with an uncaptured cursor, so mouse look only started after clicking the window. Request capture once after local player creation and after the integrated/remote client sends its level-ready notification. Capture requests now respect window focus, and loading completion leaves menus and chat alone.

The production change is 16 added lines. The reporter tested the Windows build and said world entry now seems to work; the full menu, Alt+Tab, and controller checklist has not been separately confirmed.

Vanilla reference

Pinned Minecraft Java Edition 26.3:

  • LevelLoadingScreen.tick/onClose and Screen.onClose: close the loading screen when the level is ready.
  • Gui.setScreen(null): restore gameplay and call MouseHandler.grabMouse().
  • MouseHandler.grabMouse/releaseMouse, Minecraft.isWindowActive, and Window.onFocus: distinguish gameplay capture from OS focus and reject a grab while inactive.
  • KeyboardHandler.keyPress and InputConstants.grabMouse/releaseMouse: screen input routing and relative mouse mode.

Inspected mcsrc.dev's 26.3 MouseHandler, local pinned sources, and tools/rea_vanilla.py method net.minecraft.client.MouseHandler grabMouse. The client jar SHA-1 matched research-lock.json.

tests/test_world_input_capture.py compiles the production capture method bodies against a small window/input fixture and checks grab attempts, cursor visibility, input-state changes, focus loss, menu/chat suppression, and grab failure. It also checks both loading completion call sites. Native GUI delivery and Java/Rust differential GUI parity remain unverified automatically.

Self-check

Attempted python tools/pr_ready.py --base origin/main --quick. It stops during import on native Windows because tools/parity.py calls os.uname(); no self-check block is emitted. Full workspace checks and affected vanilla harnesses remain pending CI/maintainer validation.

Check Result
Focused capture regression 2 passed
Client binary tests 55 passed, 1 ignored
Client library tests 760 passed, 3 failed, 9 ignored
cargo check --locked -p horizon-client --bin horizon-client Passed
cargo clippy --locked -p horizon-client --bin horizon-client -- -D warnings Passed
cargo fmt -p horizon-client -- --check Passed
Optimized client build Passed
Public tree, including history; diff whitespace Passed

The three library failures are in unchanged code on this Windows environment: crash::tests::stacks_start_at_the_panicking_frame, packs::cache::tests::directory_inputs_config_and_owned_output_recovery (access denied), and save::tests::session_lock_is_exclusive (Windows file locking). This PR does not modify library sources.

Opened as a draft while the full contribution gate and remaining native input checks are outstanding.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/614 **Author:** [@LookImEcho-Rick](https://github.com/LookImEcho-Rick) **Created:** 10/17/2026 **Status:** ✅ Merged **Merged:** 10/17/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `codex/fix-world-input-capture` --- ### 📝 Commits (2) - [`3230b6b`](https://github.com/horizon-rust/horizon/commit/3230b6b88d52e3de3474d596ecd67e4ce1c2a1c2) Fix mouse capture when world loading completes - [`cde0703`](https://github.com/horizon-rust/horizon/commit/cde07036455e6a72d458c65512ee0f34fe27b283) Merge main and preserve capture and mining release behavior ### 📊 Changes **3 files changed** (+171 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+15 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+1 -0) ➕ `tests/test_world_input_capture.py` (+155 -0) </details> ### 📄 Description ## What and why Fixes #612. Entering a world could leave Horizon active with an uncaptured cursor, so mouse look only started after clicking the window. Request capture once after local player creation and after the integrated/remote client sends its level-ready notification. Capture requests now respect window focus, and loading completion leaves menus and chat alone. The production change is 16 added lines. The reporter tested the Windows build and said world entry now seems to work; the full menu, Alt+Tab, and controller checklist has not been separately confirmed. ## Vanilla reference Pinned Minecraft Java Edition 26.3: - `LevelLoadingScreen.tick/onClose` and `Screen.onClose`: close the loading screen when the level is ready. - `Gui.setScreen(null)`: restore gameplay and call `MouseHandler.grabMouse()`. - `MouseHandler.grabMouse/releaseMouse`, `Minecraft.isWindowActive`, and `Window.onFocus`: distinguish gameplay capture from OS focus and reject a grab while inactive. - `KeyboardHandler.keyPress` and `InputConstants.grabMouse/releaseMouse`: screen input routing and relative mouse mode. Inspected [mcsrc.dev's 26.3 MouseHandler](https://mcsrc.dev/2/26.3/net/minecraft/client/MouseHandler), local pinned sources, and `tools/rea_vanilla.py method net.minecraft.client.MouseHandler grabMouse`. The client jar SHA-1 matched `research-lock.json`. `tests/test_world_input_capture.py` compiles the production capture method bodies against a small window/input fixture and checks grab attempts, cursor visibility, input-state changes, focus loss, menu/chat suppression, and grab failure. It also checks both loading completion call sites. Native GUI delivery and Java/Rust differential GUI parity remain unverified automatically. ## Self-check Attempted `python tools/pr_ready.py --base origin/main --quick`. It stops during import on native Windows because `tools/parity.py` calls `os.uname()`; no self-check block is emitted. Full workspace checks and affected vanilla harnesses remain pending CI/maintainer validation. | Check | Result | | --- | --- | | Focused capture regression | 2 passed | | Client binary tests | 55 passed, 1 ignored | | Client library tests | 760 passed, 3 failed, 9 ignored | | `cargo check --locked -p horizon-client --bin horizon-client` | Passed | | `cargo clippy --locked -p horizon-client --bin horizon-client -- -D warnings` | Passed | | `cargo fmt -p horizon-client -- --check` | Passed | | Optimized client build | Passed | | Public tree, including history; diff whitespace | Passed | The three library failures are in unchanged code on this Windows environment: `crash::tests::stacks_start_at_the_panicking_frame`, `packs::cache::tests::directory_inputs_config_and_owned_output_recovery` (access denied), and `save::tests::session_lock_is_exclusive` (Windows file locking). This PR does not modify library sources. Opened as a draft while the full contribution gate and remaining native input checks are outstanding. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:58:10 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#2678
No description provided.