[PR #3403] [CLOSED] Mouse wheel: one hotbar step per notch on Wayland (winit 0.31) #4957

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3403
Author: @spidercraft
Created: 10/28/2026
Status: ❌ Closed

Base: main ← Head: winit-0.31


📝 Commits (3)

  • c97fb32 Mouse wheel: one hotbar step per notch on Wayland (winit 0.31)
  • 25d81f5 Merge main into winit-0.31
  • 528e24e Merge main into this branch after the render crate split (#3186)

📊 Changes

21 files changed (+675 additions, -562 deletions)

View changed files

📝 Cargo.lock (+356 -390)
📝 crates/horizon-client-input/Cargo.toml (+1 -1)
📝 crates/horizon-client-input/src/keybinds.rs (+3 -3)
📝 crates/horizon-client-input/src/window.rs (+4 -2)
📝 crates/horizon-client-render/Cargo.toml (+1 -1)
📝 crates/horizon-client-render/src/gfx.rs (+4 -4)
📝 crates/horizon-client-render/src/telemetry.rs (+8 -5)
📝 crates/horizon-client/Cargo.toml (+1 -1)
📝 crates/horizon-client/src/game.rs (+172 -81)
📝 crates/horizon-client/src/game/agent.rs (+31 -18)
📝 crates/horizon-client/src/game/chat.rs (+1 -1)
📝 crates/horizon-client/src/game/clipboard.rs (+1 -1)
📝 crates/horizon-client/src/game/control.rs (+18 -11)
📝 crates/horizon-client/src/game/debug_keys.rs (+3 -3)
📝 crates/horizon-client/src/game/dialogs.rs (+1 -1)
📝 crates/horizon-client/src/game/options.rs (+1 -1)
📝 crates/horizon-client/src/game/pad.rs (+4 -4)
📝 crates/horizon-client/src/game/pad_menu.rs (+44 -21)
📝 crates/horizon-client/src/game/startup_menu.rs (+19 -11)
📝 crates/horizon-client/src/game/ui_control.rs (+1 -1)

...and 1 more files

📄 Description

🤖 Opened by Claude Code.

What and why

On Wayland, a mouse with a high-resolution wheel (a Logitech G903 here, on Hyprland 0.56.2) sometimes moved the hotbar two slots for one notch, or stepped before the notch clicked.

winit 0.30 binds wl_seat v7, which has no axis_value120, so the compositor converts hi-res wheel ticks into discrete steps for us. Hyprland's conversion (InputManager::onMouseWheel, emulate_discrete_scroll) sends one step on the first tick of a burst "for responsiveness", then another per 120 units built up in the burst, without subtracting the first one. A logger window on winit 0.30.13 showed most upward notches arriving as two LineDelta(1). Through XWayland, the same wheel sends 1/8-line deltas that add up to one line per notch, which ScrollWheelHandler already handles.

winit 0.31's Wayland backend reads axis_value120 (LineDelta = value120 / 120), so this moves the game to winit 0.31.0-beta.4. The scroll code itself is unchanged.

Porting notes:

  • Window and ActiveEventLoop are traits now: Arc<dyn Window>, &dyn ActiveEventLoop.
  • The window is created in can_create_surfaces (was resumed).
  • exiting is gone. The exit save runs when a small Exiting wrapper is dropped. winit drops the handler on macOS applicationWillTerminate (winit-common EventHandler::terminate), so Cmd+Q still saves.
  • run_app needs a 'static app, so the game uses run_app_on_demand.
  • MouseInput/CursorMoved become PointerButton { button: ButtonSource::Mouse(..) }/PointerMoved, including the events that agent control and the controller menu synthesize. MouseWheel takes a ScrollSource.
  • KeyCode is keyboard_types::Code: Super* becomes Meta* (the key.keyboard.left.win names stay). MouseButton::Other is gone.
  • Monitor size and refresh come from current_video_mode(). The icon uses winit::icon::RgbaIcon. The Wayland app id goes through WindowAttributesWayland.
  • tests/test_world_input_capture.py: the stub window's inner_size becomes surface_size.

Tested on Linux (Hyprland): the window opens with app id horizon, the display reads 3840×2160 @ 240 Hz, closing the window saves the world, and the hotbar steps once per notch. Not tested on macOS or Windows: CI is the first compile there.

winit 0.31 is a beta. The diff is about 480 lines plus Cargo.lock, and can't be split, because the version bump only compiles together with the port.

Vanilla reference

MouseHandler.onScroll / ScrollWheelHandler (unchanged here). Vanilla's GLFW goes through XWayland, which sends one step per notch.

Self-check

pr_ready (tools/pr_ready.py on SpiderPC, against origin/main at 11b8757bc, 1 min 7 s)

Check Result
Scope ⚠️ 20 files, +668 −559; 1225 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ changes with a Cargo.toml
Public tree ✅
Python tests ✅ 405 passed (24 s)
rustfmt ✅ (4 s)
clippy ✅ (6 s)
tests: workspace ❌ 1651 passed, 32 failed (25 s)
doc tests ✅ 2 passed (3 s)
content root tests ✅ 5 passed (1 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ✅
launcher clippy ✅ (1 s)
launcher tests ✅ 239 passed (3 s)
Parity ➖ 348 affected, to run in CI (no vanilla data here): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 336 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

The 32 workspace failures are horizon-mods --test sandbox: this machine has no wasm32-unknown-unknown target to build the test guests. horizon-mods doesn't depend on winit.

🤖 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/3403 **Author:** [@spidercraft](https://github.com/spidercraft) **Created:** 10/28/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `winit-0.31` --- ### 📝 Commits (3) - [`c97fb32`](https://github.com/horizon-rust/horizon/commit/c97fb32f8757ea94c674bf6054cc2b26d31a4930) Mouse wheel: one hotbar step per notch on Wayland (winit 0.31) - [`25d81f5`](https://github.com/horizon-rust/horizon/commit/25d81f58346cef713157fc26ddcf49beee0ace72) Merge main into winit-0.31 - [`528e24e`](https://github.com/horizon-rust/horizon/commit/528e24eaab657a3a194e17c0facdf44d43877194) Merge main into this branch after the render crate split (#3186) ### 📊 Changes **21 files changed** (+675 additions, -562 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+356 -390) 📝 `crates/horizon-client-input/Cargo.toml` (+1 -1) 📝 `crates/horizon-client-input/src/keybinds.rs` (+3 -3) 📝 `crates/horizon-client-input/src/window.rs` (+4 -2) 📝 `crates/horizon-client-render/Cargo.toml` (+1 -1) 📝 `crates/horizon-client-render/src/gfx.rs` (+4 -4) 📝 `crates/horizon-client-render/src/telemetry.rs` (+8 -5) 📝 `crates/horizon-client/Cargo.toml` (+1 -1) 📝 `crates/horizon-client/src/game.rs` (+172 -81) 📝 `crates/horizon-client/src/game/agent.rs` (+31 -18) 📝 `crates/horizon-client/src/game/chat.rs` (+1 -1) 📝 `crates/horizon-client/src/game/clipboard.rs` (+1 -1) 📝 `crates/horizon-client/src/game/control.rs` (+18 -11) 📝 `crates/horizon-client/src/game/debug_keys.rs` (+3 -3) 📝 `crates/horizon-client/src/game/dialogs.rs` (+1 -1) 📝 `crates/horizon-client/src/game/options.rs` (+1 -1) 📝 `crates/horizon-client/src/game/pad.rs` (+4 -4) 📝 `crates/horizon-client/src/game/pad_menu.rs` (+44 -21) 📝 `crates/horizon-client/src/game/startup_menu.rs` (+19 -11) 📝 `crates/horizon-client/src/game/ui_control.rs` (+1 -1) _...and 1 more files_ </details> ### 📄 Description > 🤖 Opened by Claude Code. ## What and why On Wayland, a mouse with a high-resolution wheel (a Logitech G903 here, on Hyprland 0.56.2) sometimes moved the hotbar two slots for one notch, or stepped before the notch clicked. winit 0.30 binds `wl_seat` v7, which has no `axis_value120`, so the compositor converts hi-res wheel ticks into discrete steps for us. Hyprland's conversion (`InputManager::onMouseWheel`, `emulate_discrete_scroll`) sends one step on the first tick of a burst "for responsiveness", then another per 120 units built up in the burst, without subtracting the first one. A logger window on winit 0.30.13 showed most upward notches arriving as two `LineDelta(1)`. Through XWayland, the same wheel sends 1/8-line deltas that add up to one line per notch, which `ScrollWheelHandler` already handles. winit 0.31's Wayland backend reads `axis_value120` (`LineDelta = value120 / 120`), so this moves the game to `winit 0.31.0-beta.4`. The scroll code itself is unchanged. Porting notes: - `Window` and `ActiveEventLoop` are traits now: `Arc<dyn Window>`, `&dyn ActiveEventLoop`. - The window is created in `can_create_surfaces` (was `resumed`). - `exiting` is gone. The exit save runs when a small `Exiting` wrapper is dropped. winit drops the handler on macOS `applicationWillTerminate` (`winit-common` `EventHandler::terminate`), so Cmd+Q still saves. - `run_app` needs a `'static` app, so the game uses `run_app_on_demand`. - `MouseInput`/`CursorMoved` become `PointerButton { button: ButtonSource::Mouse(..) }`/`PointerMoved`, including the events that agent control and the controller menu synthesize. `MouseWheel` takes a `ScrollSource`. - `KeyCode` is `keyboard_types::Code`: `Super*` becomes `Meta*` (the `key.keyboard.left.win` names stay). `MouseButton::Other` is gone. - Monitor size and refresh come from `current_video_mode()`. The icon uses `winit::icon::RgbaIcon`. The Wayland app id goes through `WindowAttributesWayland`. - `tests/test_world_input_capture.py`: the stub window's `inner_size` becomes `surface_size`. Tested on Linux (Hyprland): the window opens with app id `horizon`, the display reads 3840×2160 @ 240 Hz, closing the window saves the world, and the hotbar steps once per notch. **Not tested on macOS or Windows**: CI is the first compile there. winit 0.31 is a beta. The diff is about 480 lines plus Cargo.lock, and can't be split, because the version bump only compiles together with the port. ## Vanilla reference `MouseHandler.onScroll` / `ScrollWheelHandler` (unchanged here). Vanilla's GLFW goes through XWayland, which sends one step per notch. ## Self-check **pr_ready** (`tools/pr_ready.py` on SpiderPC, against origin/main at 11b8757bc, 1 min 7 s) | Check | Result | | --- | --- | | Scope | ⚠️ 20 files, +668 −559; 1225 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ changes with a Cargo.toml | | Public tree | ✅ | | Python tests | ✅ 405 passed (24 s) | | rustfmt | ✅ (4 s) | | clippy | ✅ (6 s) | | tests: workspace | ❌ 1651 passed, 32 failed (25 s) | | doc tests | ✅ 2 passed (3 s) | | content root tests | ✅ 5 passed (1 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ✅ | | launcher clippy | ✅ (1 s) | | launcher tests | ✅ 239 passed (3 s) | | Parity | ➖ 348 affected, to run in CI (no vanilla data here): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 336 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | The 32 workspace failures are `horizon-mods --test sandbox`: this machine has no `wasm32-unknown-unknown` target to build the test guests. horizon-mods doesn't depend on winit. 🤖 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:09: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#4957
No description provided.