[PR #3839] [MERGED] --offscreen: hide the window and leave the system pointer alone #5243

Closed
opened 2026-11-03 05:11:12 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3839
Author: @GIGABAIT93
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @rdbtCVS

Base: main ← Head: fix/offscreen-pointer


📝 Commits (2)

  • 4264d34 --offscreen: hide the window and leave the system pointer alone
  • e855ded Test that an offscreen game never grabs, warps or hides the pointer

📊 Changes

2 files changed (+44 additions, -7 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+22 -5)
📝 tests/test_world_input_capture.py (+22 -2)

📄 Description

🤖 Opened by GIGABAIT93's AI agent (Claude Code, Claude Opus 5.5), not by GIGABAIT93 directly.

What

--offscreen renders into a texture, so its window only ever shows white. Even so, entering a world grabbed the system pointer. On Windows, the pointer was clipped to a single pixel even while that white window wasn't in front, and it stayed stuck until the person at the computer alt-tabbed. Every agent run (horizon-ctl launch --offscreen, the launcher MCP's play with offscreen) did this to whoever was using the machine.

  • The window is created hidden under --offscreen (both creation sites: the loading screen's and the game's own). This is what horizon-ctl's help already promises: "render without showing a window".
  • capture keeps the grab as the game's own state under --offscreen. It never grabs, warps or hides the system pointer. pointer_grabbed, screens and agent input are unchanged: agents turn the view with mouse-move.
  • Raw mouse motion (DeviceEvent::MouseMotion) never steers an offscreen game, because its pointer is no longer grabbed.

Nothing changes without --offscreen.

tests/test_world_input_capture.py compiles the client's own capture body against a fake window. It now carries the game's options and checks that an offscreen game grabs and releases as its own state, with no grab, warp or visibility change on the window. On the base it fails: 2 grabs and 4 warps.

Proof (Windows 11)

The real horizon-client, --world PointerProof --creative --offscreen --control-socket, driven with horizon-ctl, with the desktop read through Win32 (IsWindowVisible, GetClipCursor, GetForegroundWindow). The before build is 8f0c17895, whose window and pointer code is identical to this branch's base. after is this branch.

before after
Game window visible yes (white) no
Game window in front no no
System pointer clipped, in the world yes, to 1×1 px ([4182,752,4183,753]) no (the whole desktop)
Inventory open (key e) not clipped not clipped
Back in the world (key escape) clipped to 1×1 px again not clipped
state.pointer_grabbed in the world true true
mouse-move 300 0 turns the view yes yes
Screen after key e creative creative
screenshot from the offscreen frame 805 KB PNG 548 KB PNG, a real frame of the world
quit exit code 0 0

Not covered: macOS and Linux were not run by hand. The change there is the same with_visible(false) plus not calling set_cursor_grab, and the offscreen frame already draws without waiting for the window (the locked-Mac case). tools/pr_ready.py --quick passed on Linux (block below).

pr_ready (tools/pr_ready.py --quick --base upstream/main on GIGABAIT, against upstream/main at c7065027b, 1 min 28 s)

Check Result
Scope ✅ 2 files, +44 −7
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 423 passed (43 s)
rustfmt ✅ (29 s)
clippy ✅ (5 s)
tests: horizon-client ✅ 869 passed (5 s)
doc tests ✅ 0 passed (5 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 Generated with Claude Code


🔄 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/3839 **Author:** [@GIGABAIT93](https://github.com/GIGABAIT93) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/offscreen-pointer` --- ### 📝 Commits (2) - [`4264d34`](https://github.com/horizon-rust/horizon/commit/4264d34f1c9b311e7999dc3f24877083d65bb6e5) --offscreen: hide the window and leave the system pointer alone - [`e855ded`](https://github.com/horizon-rust/horizon/commit/e855ded821c73eba802ec6f5984f3a68d7ecd59d) Test that an offscreen game never grabs, warps or hides the pointer ### 📊 Changes **2 files changed** (+44 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+22 -5) 📝 `tests/test_world_input_capture.py` (+22 -2) </details> ### 📄 Description > 🤖 Opened by GIGABAIT93's AI agent (Claude Code, Claude Opus 5.5), not by GIGABAIT93 directly. ## What `--offscreen` renders into a texture, so its window only ever shows white. Even so, entering a world grabbed the system pointer. On Windows, the pointer was clipped to a single pixel even while that white window wasn't in front, and it stayed stuck until the person at the computer alt-tabbed. Every agent run (`horizon-ctl launch --offscreen`, the launcher MCP's `play` with `offscreen`) did this to whoever was using the machine. - The window is created hidden under `--offscreen` (both creation sites: the loading screen's and the game's own). This is what `horizon-ctl`'s help already promises: "render without showing a window". - `capture` keeps the grab as the game's own state under `--offscreen`. It never grabs, warps or hides the system pointer. `pointer_grabbed`, screens and agent input are unchanged: agents turn the view with `mouse-move`. - Raw mouse motion (`DeviceEvent::MouseMotion`) never steers an offscreen game, because its pointer is no longer grabbed. Nothing changes without `--offscreen`. `tests/test_world_input_capture.py` compiles the client's own `capture` body against a fake window. It now carries the game's options and checks that an offscreen game grabs and releases as its own state, with no grab, warp or visibility change on the window. On the base it fails: 2 grabs and 4 warps. ## Proof (Windows 11) The real `horizon-client`, `--world PointerProof --creative --offscreen --control-socket`, driven with `horizon-ctl`, with the desktop read through Win32 (`IsWindowVisible`, `GetClipCursor`, `GetForegroundWindow`). The `before` build is `8f0c17895`, whose window and pointer code is identical to this branch's base. `after` is this branch. | | before | after | | --- | --- | --- | | Game window visible | yes (white) | **no** | | Game window in front | no | no | | System pointer clipped, in the world | **yes, to 1×1 px** (`[4182,752,4183,753]`) | no (the whole desktop) | | Inventory open (`key e`) | not clipped | not clipped | | Back in the world (`key escape`) | **clipped to 1×1 px** again | not clipped | | `state.pointer_grabbed` in the world | true | true | | `mouse-move 300 0` turns the view | yes | yes | | Screen after `key e` | `creative` | `creative` | | `screenshot` from the offscreen frame | 805 KB PNG | 548 KB PNG, a real frame of the world | | `quit` exit code | 0 | 0 | Not covered: macOS and Linux were not run by hand. The change there is the same `with_visible(false)` plus not calling `set_cursor_grab`, and the offscreen frame already draws without waiting for the window (the locked-Mac case). `tools/pr_ready.py --quick` passed on Linux (block below). **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on GIGABAIT, against upstream/main at c7065027b, 1 min 28 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +44 −7 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 423 passed (43 s) | | rustfmt | ✅ (29 s) | | clippy | ✅ (5 s) | | tests: horizon-client | ✅ 869 passed (5 s) | | doc tests | ✅ 0 passed (5 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:11:12 +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#5243
No description provided.