[PR #4367] [MERGED] Controls: implement Quit Shortcuts toggle and window-close blocking #5584

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

📋 Pull Request Information

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

Base: main ← Head: feat/quit-shortcuts


📝 Commits (3)

  • 59a1f51 Controls: implement Quit Shortcuts toggle and window-close blocking
  • 7ba8d7e Merge branch 'main' into feat/quit-shortcuts
  • 6020358 Fix syntax error and Opt::available in options_ui.rs after merge

📊 Changes

4 files changed (+122 additions, -2 deletions)

View changed files

📝 crates/horizon-client-input/src/input.rs (+45 -0)
📝 crates/horizon-client-render/src/options_ui.rs (+12 -2)
📝 crates/horizon-client/src/game.rs (+57 -0)
📝 crates/horizon-client/src/game/startup_menu.rs (+8 -0)

📄 Description

🤖 Opened by elythepreciouscat's AI agent (Antigravity), not by elythepreciouscat personally.

Summary

Implements vanilla 26.3 quit shortcut detection and window-close blocking (InputQuirks.isQuitShortcutDown / Window.onQuitRequested) and enables the Quit Shortcuts toggle in Controls (Opt::QuitShortcuts).

Background

In vanilla Minecraft 26.3 Java Edition (net.minecraft.client.Options):

  • The quitShortcuts option (default true) allows players to prevent accidental quits from keyboard shortcuts (Alt+F4 on Windows/Linux, Cmd+Q on macOS).
  • When quitShortcuts is disabled (false), Window.onQuitRequested() checks InputQuirks.isQuitShortcutDown(). If the window close request originated from the quit shortcut key combination, the request is ignored, while clicking the window close button still closes the game normally.

In Horizon:

  • quit_shortcuts was already serialized and loaded in options.txt and toggled in options_ui.rs, but was marked unavailable in Opt::available() ("quit keys don't read them yet") and greyed out.
  • WindowEvent::CloseRequested in game.rs and startup_menu.rs immediately exited without checking is_quit_shortcut_down.

Changes

  1. horizon-client-input (input.rs):
    • Added is_quit_shortcut_down(modifiers: ModifiersState, keys: &HashSet<KeyCode>) -> bool matching vanilla InputQuirks.isQuitShortcutDown (Command+Q on macOS, Alt+F4 on other platforms).
    • Added unit test quit_shortcut_follows_platform_modifiers_and_keys.
  2. horizon-client (game.rs and game/startup_menu.rs):
    • On WindowEvent::CloseRequested, if !self.settings.quit_shortcuts && is_quit_shortcut_down(...), ignore the close request.
    • Added unit test quit_shortcut_blocks_window_close_when_option_disabled.
  3. horizon-client-render (options_ui.rs):
    • Removed Opt::QuitShortcuts from Opt::available() exclusion list, enabling the option in Controls with its vanilla tooltip (options.quitShortcuts.tooltip).
    • Added unit test quit_shortcuts_option_can_be_switched.

Fixes #4336
Part of #3518

Verification

  • tools/pr_ready.py --quick: passed all 480 Python tests, rustfmt, clippy, and 1,605 unit tests across horizon-client, horizon-client-input, and horizon-client-render.

🤖 Generated with Antigravity.


🔄 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/4367 **Author:** [@elythepreciouscat](https://github.com/elythepreciouscat) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `feat/quit-shortcuts` --- ### 📝 Commits (3) - [`59a1f51`](https://github.com/horizon-rust/horizon/commit/59a1f51d346b5bbea210f48ebe4419fb19bdb370) Controls: implement Quit Shortcuts toggle and window-close blocking - [`7ba8d7e`](https://github.com/horizon-rust/horizon/commit/7ba8d7ee65d7863c3e9958cc18350ef342db1065) Merge branch 'main' into feat/quit-shortcuts - [`6020358`](https://github.com/horizon-rust/horizon/commit/60203586ca47d68c7fffe561bc33be607ba1b53b) Fix syntax error and Opt::available in options_ui.rs after merge ### 📊 Changes **4 files changed** (+122 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-input/src/input.rs` (+45 -0) 📝 `crates/horizon-client-render/src/options_ui.rs` (+12 -2) 📝 `crates/horizon-client/src/game.rs` (+57 -0) 📝 `crates/horizon-client/src/game/startup_menu.rs` (+8 -0) </details> ### 📄 Description > 🤖 Opened by elythepreciouscat's AI agent (Antigravity), not by elythepreciouscat personally. ### Summary Implements vanilla 26.3 quit shortcut detection and window-close blocking (`InputQuirks.isQuitShortcutDown` / `Window.onQuitRequested`) and enables the `Quit Shortcuts` toggle in Controls (`Opt::QuitShortcuts`). ### Background In vanilla Minecraft 26.3 Java Edition (`net.minecraft.client.Options`): - The `quitShortcuts` option (default `true`) allows players to prevent accidental quits from keyboard shortcuts (Alt+F4 on Windows/Linux, Cmd+Q on macOS). - When `quitShortcuts` is disabled (`false`), `Window.onQuitRequested()` checks `InputQuirks.isQuitShortcutDown()`. If the window close request originated from the quit shortcut key combination, the request is ignored, while clicking the window close button still closes the game normally. In Horizon: - `quit_shortcuts` was already serialized and loaded in `options.txt` and toggled in `options_ui.rs`, but was marked unavailable in `Opt::available()` ("quit keys don't read them yet") and greyed out. - `WindowEvent::CloseRequested` in `game.rs` and `startup_menu.rs` immediately exited without checking `is_quit_shortcut_down`. ### Changes 1. **`horizon-client-input` (`input.rs`)**: - Added `is_quit_shortcut_down(modifiers: ModifiersState, keys: &HashSet<KeyCode>) -> bool` matching vanilla `InputQuirks.isQuitShortcutDown` (Command+Q on macOS, Alt+F4 on other platforms). - Added unit test `quit_shortcut_follows_platform_modifiers_and_keys`. 2. **`horizon-client` (`game.rs` and `game/startup_menu.rs`)**: - On `WindowEvent::CloseRequested`, if `!self.settings.quit_shortcuts && is_quit_shortcut_down(...)`, ignore the close request. - Added unit test `quit_shortcut_blocks_window_close_when_option_disabled`. 3. **`horizon-client-render` (`options_ui.rs`)**: - Removed `Opt::QuitShortcuts` from `Opt::available()` exclusion list, enabling the option in Controls with its vanilla tooltip (`options.quitShortcuts.tooltip`). - Added unit test `quit_shortcuts_option_can_be_switched`. Fixes #4336 Part of #3518 ### Verification - `tools/pr_ready.py --quick`: passed all 480 Python tests, rustfmt, clippy, and 1,605 unit tests across `horizon-client`, `horizon-client-input`, and `horizon-client-render`. 🤖 Generated with [Antigravity](https://deepmind.google/technologies/gemini/). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:13:34 +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#5584
No description provided.