[PR #4996] [MERGED] Game: its event handlers take a loop handle, not winit's loop (#4951, 1/2) #5996

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4996
Author: @Solenopsisbot
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @ludovic111

Base: main ← Head: headless/loop-handle


📝 Commits (6)

  • a4d4813 Game: its event handlers take a loop handle, not winit's loop
  • b323704 Merge origin/main into headless/loop-handle
  • a190c13 Merge origin/main into headless/loop-handle (main's clippy fix #5304)
  • a11de0a Merge origin/main into headless/loop-handle (main's Python suite fix)
  • b42aa49 Merge remote-tracking branch 'origin/main' into sweepc-4996
  • 35f85fd Merge origin/main into headless/loop-handle

📊 Changes

8 files changed (+124 additions, -71 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+50 -28)
📝 crates/horizon-client/src/game/agent.rs (+9 -10)
📝 crates/horizon-client/src/game/control.rs (+6 -5)
➕ crates/horizon-client/src/game/event_loop.rs (+24 -0)
📝 crates/horizon-client/src/game/pad.rs (+6 -5)
📝 crates/horizon-client/src/game/pad_menu.rs (+23 -19)
📝 crates/horizon-client/src/game/startup_menu.rs (+3 -2)
📝 crates/horizon-client/src/game/ui_control.rs (+3 -2)

📄 Description

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

What and why

Part 1 of #4951 (a headless client). It changes no behaviour; it removes the one thing that ties the game's methods to winit's event loop.

A headless client has no display, so it can't run winit's EventLoop: EventLoop::new() fails without DISPLAY or WAYLAND_DISPLAY, even for --offscreen. The game's methods took &ActiveEventLoop only to stop the loop (exit, 28 calls) and to say when to wake next (set_control_flow). They now take &dyn EventLoopCtl, a two-method trait in game/event_loop.rs that winit's ActiveEventLoop implements. Callers pass event_loop as before, through unsized coercion.

  • window_event and about_to_wait keep their bodies, in the same place, as the inherent handle_window_event and idle. The ApplicationHandler methods forward to them. device_event and exiting move up into the trait impl unchanged.
  • The control socket's and the pad menu's synthetic input (synth_click, synth_drag, the scroll command, pad_pointer_to...) call handle_window_event. That is the path a headless game's input will take.
  • title_action, poll_control, poll_pads, the pad-menu functions, menu_action/menu_event and the agent's answer take the handle.
  • no_resources.rs and the loading screen stay on winit: they only exist with a window.

Part 2 (#4951's --headless flag, the game's own loop) builds on this and is ready on Solenopsisbot:headless/client. It opens once this one is reviewed.

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

None of these fit: it's a refactor that players don't see (skip-release).

Vanilla reference

None: the event loop is Horizon's own (vanilla's GLFW loop has no equivalent split).

Self-check

pr_ready (tools/pr_ready.py on cytonic, Linux x86_64, against origin/main at 19021623b, 118 min 43 s)

Check Result
Scope ✅ 8 files, +123 −70
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 487 passed (41 s)
rustfmt ✅ (9 s)
clippy ✅ (1 min 31 s)
tests: horizon-client ❌ 913 passed, 1 failed (4 min 4 s)
doc tests ✅ 0 passed (1 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 ❌ 367 affected, 361 passed, failed: block_update, dedicated_server, mob_ai, random_tick, secure_chat (112 min 17 s)

The failures are main's, not this branch's. A clean worktree of main at 19021623b, run on the same machine with fresh oracle runs (tools/parity.py --fresh block_update dedicated_server mob_ai random_tick secure_chat), fails the same five harnesses with identical differences. Main also fails the same library test (motion::tests::a_swimming_passenger_sits_up_even_when_standing_does_not_fit). This branch changes only the game binary's event-loop plumbing.

  • block_update and random_tick: structure_block and test_block run a neighbour and tick hook (X structure_block, X test_block_tick) that vanilla doesn't record.
  • mob_ai: bee_sting misses entity.player.hurt at tick 67.
  • dedicated_server and secure_chat: one extra multiplayer.player.joined system message per player at play start.

Also run by hand: a game started with horizon-ctl launch --offscreen (Vulkan, GTX 970) opens a world, answers state, walks, and takes a screenshot.

🤖 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/4996 **Author:** [@Solenopsisbot](https://github.com/Solenopsisbot) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `headless/loop-handle` --- ### 📝 Commits (6) - [`a4d4813`](https://github.com/horizon-rust/horizon/commit/a4d481311f9a250615a20c500cdbf3083cdd38af) Game: its event handlers take a loop handle, not winit's loop - [`b323704`](https://github.com/horizon-rust/horizon/commit/b323704770bfa7f4aba2f19af4a934fc427a5192) Merge origin/main into headless/loop-handle - [`a190c13`](https://github.com/horizon-rust/horizon/commit/a190c1382491cc4c1b380033496c59203bbdee87) Merge origin/main into headless/loop-handle (main's clippy fix #5304) - [`a11de0a`](https://github.com/horizon-rust/horizon/commit/a11de0a95f70c4e5ef0b0bbf3826c52b8c4515ff) Merge origin/main into headless/loop-handle (main's Python suite fix) - [`b42aa49`](https://github.com/horizon-rust/horizon/commit/b42aa496ee1285e73105a68609044d6c032d9ac1) Merge remote-tracking branch 'origin/main' into sweepc-4996 - [`35f85fd`](https://github.com/horizon-rust/horizon/commit/35f85fd88db6201423a0e8066be0c7f5c70376ae) Merge origin/main into headless/loop-handle ### 📊 Changes **8 files changed** (+124 additions, -71 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+50 -28) 📝 `crates/horizon-client/src/game/agent.rs` (+9 -10) 📝 `crates/horizon-client/src/game/control.rs` (+6 -5) ➕ `crates/horizon-client/src/game/event_loop.rs` (+24 -0) 📝 `crates/horizon-client/src/game/pad.rs` (+6 -5) 📝 `crates/horizon-client/src/game/pad_menu.rs` (+23 -19) 📝 `crates/horizon-client/src/game/startup_menu.rs` (+3 -2) 📝 `crates/horizon-client/src/game/ui_control.rs` (+3 -2) </details> ### 📄 Description > 🤖 Opened by Solenopsisbot's AI agent (Claude Code, Claude Opus 5.5), not by Solenopsisbot personally. ## What and why Part 1 of #4951 (a headless client). It changes no behaviour; it removes the one thing that ties the game's methods to winit's event loop. A headless client has no display, so it can't run winit's `EventLoop`: `EventLoop::new()` fails without `DISPLAY` or `WAYLAND_DISPLAY`, even for `--offscreen`. The game's methods took `&ActiveEventLoop` only to stop the loop (`exit`, 28 calls) and to say when to wake next (`set_control_flow`). They now take `&dyn EventLoopCtl`, a two-method trait in `game/event_loop.rs` that winit's `ActiveEventLoop` implements. Callers pass `event_loop` as before, through unsized coercion. - `window_event` and `about_to_wait` keep their bodies, in the same place, as the inherent `handle_window_event` and `idle`. The `ApplicationHandler` methods forward to them. `device_event` and `exiting` move up into the trait impl unchanged. - The control socket's and the pad menu's synthetic input (`synth_click`, `synth_drag`, the `scroll` command, `pad_pointer_to`...) call `handle_window_event`. That is the path a headless game's input will take. - `title_action`, `poll_control`, `poll_pads`, the pad-menu functions, `menu_action`/`menu_event` and the agent's `answer` take the handle. - `no_resources.rs` and the loading screen stay on winit: they only exist with a window. Part 2 (#4951's `--headless` flag, the game's own loop) builds on this and is ready on [`Solenopsisbot:headless/client`](https://github.com/Solenopsisbot/horizon/compare/headless/loop-handle...headless/client). It opens once this one is reviewed. ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs None of these fit: it's a refactor that players don't see (`skip-release`). ## Vanilla reference None: the event loop is Horizon's own (vanilla's GLFW loop has no equivalent split). ## Self-check **pr_ready** (`tools/pr_ready.py` on cytonic, Linux x86_64, against origin/main at 19021623b, 118 min 43 s) | Check | Result | | --- | --- | | Scope | ✅ 8 files, +123 −70 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 487 passed (41 s) | | rustfmt | ✅ (9 s) | | clippy | ✅ (1 min 31 s) | | tests: horizon-client | ❌ 913 passed, 1 failed (4 min 4 s) | | doc tests | ✅ 0 passed (1 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 | ❌ 367 affected, 361 passed, failed: block_update, dedicated_server, mob_ai, random_tick, secure_chat (112 min 17 s) | **The failures are main's, not this branch's.** A clean worktree of main at 19021623b, run on the same machine with fresh oracle runs (`tools/parity.py --fresh block_update dedicated_server mob_ai random_tick secure_chat`), fails the same five harnesses with identical differences. Main also fails the same library test (`motion::tests::a_swimming_passenger_sits_up_even_when_standing_does_not_fit`). This branch changes only the game binary's event-loop plumbing. - `block_update` and `random_tick`: `structure_block` and `test_block` run a neighbour and tick hook (`X structure_block`, `X test_block_tick`) that vanilla doesn't record. - `mob_ai`: `bee_sting` misses `entity.player.hurt` at tick 67. - `dedicated_server` and `secure_chat`: one extra `multiplayer.player.joined` system message per player at play start. Also run by hand: a game started with `horizon-ctl launch --offscreen` (Vulkan, GTX 970) opens a world, answers `state`, walks, and takes a screenshot. 🤖 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:16:30 +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#5996
No description provided.