[PR #3673] [MERGED] Type AltGr characters into chat and search boxes on Windows #5142

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3673
Author: @d3grando
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @levzzz5154

Base: main ← Head: fix-3001


📝 Commits (1)

  • 63b8018 Type AltGr characters into chat and search boxes on Windows

📊 Changes

7 files changed (+55 additions, -6 deletions)

View changed files

📝 crates/horizon-client-input/src/clipboard.rs (+29 -0)
📝 crates/horizon-client/src/game/chat.rs (+1 -1)
📝 crates/horizon-client/src/game/clipboard.rs (+16 -0)
📝 crates/horizon-client/src/game/command_blocks.rs (+2 -1)
📝 crates/horizon-client/src/game/lan_screen.rs (+3 -2)
📝 crates/horizon-client/src/game/native_panel.rs (+2 -1)
📝 crates/horizon-client/src/game/recipe_book.rs (+2 -1)

📄 Description

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

Fixes #3001

What and why

On Windows, Ctrl+Alt is AltGr: a layout's third-level characters arrive as text while a Control key is down. ABNT2 types / on Ctrl+Alt+Q, German types @, { and [ that way, and Polish types its letters (ą, ę, ...). The chat box dropped all of these. chat_key_code only passed typed text on when no Control key was held (typed_text && !ctrl), so pressing Ctrl+Alt+Q with ABNT2 typed nothing.

The same !ctrl gate sat in front of the command block's command field, the LAN world options' fields (port and game rules), the recipe book search and the mod item panel search. All of them now use one check, clipboard::types_text. Text is dropped only when the edit modifier (Ctrl, or Cmd on macOS) is held without Alt. Ctrl+A/C/V/X and other Ctrl shortcuts still type nothing. ALTGR_IS_CTRL_ALT is true on Windows only. Elsewhere AltGr is its own modifier and Control is never held for it, so Linux and macOS behave as before.

Sign, book, anvil, title and creative-search input never had the gate and are unchanged.

Root cause: winit hides the fake Control that a real AltGr key adds, but only when the layout reports AltGr and the right Alt follows at once. Ctrl+Alt pressed by hand (as on the reporter's US keyboard with the ABNT2 layout) is a real Control press. That press stayed in the held keys, and the !ctrl gate then dropped the character.

Vanilla reference

  • KeyboardHandler.textInput(long, String) passes every code point to charTyped(long, CharacterEvent). CharacterEvent carries only the code point, so no modifier check happens.
  • EditBox.charTyped(CharacterEvent) checks only canConsumeInput(), CharacterEvent.isAllowedChatCharacter() and isEditable, then calls insertText.

Text that would not type in vanilla is still rejected the same way as before, by type_text/insert_text's isAllowedChatCharacter filter.

Tests

New unit test clipboard::tests::altgr_types_text_where_it_is_ctrl_alt (horizon-client-input).

Before (only the helper's body put back to the old rule, !edit_modifier):

test clipboard::tests::altgr_types_text_where_it_is_ctrl_alt ... FAILED
thread 'clipboard::tests::altgr_types_text_where_it_is_ctrl_alt' panicked at crates\horizon-client-input\src\clipboard.rs:329:9:
assertion failed: types_text(true, true, true)
test result: FAILED. 6 passed; 1 failed

After:

running 7 tests
test clipboard::tests::altgr_types_text_where_it_is_ctrl_alt ... ok
...
test result: ok. 7 passed; 0 failed

In game (Windows 11)

I opened chat in a fresh creative world. Then I posted Ctrl+Alt+Q to the game window five times, with the characters a layout gives for it (/, @, {, [, ą). Each time it got the left Control, the left Alt, Q and its WM_CHAR, with the thread's key state set to match, as for real input. I read the chat box through the control socket:

  • before (current main): chat_input: "". Every character was swallowed.
  • after: chat_input: "/@{[ą". The / also opens command suggestions, as typing / does.

Self-check

cargo fmt --all -- --check                                                   # ok
cargo clippy -p horizon-client-input --all-targets -- -D warnings            # ok
cargo clippy -p horizon-client --features mods --all-targets -- -D warnings  # ok
cargo test -p horizon-client-input --lib clipboard                           # 7 passed
cargo build --profile fast -p horizon-client --features mods --bins          # ok

(tools/pr_ready.py was not run: it doesn't run on Windows.)

🤖 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/3673 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-3001` --- ### 📝 Commits (1) - [`63b8018`](https://github.com/horizon-rust/horizon/commit/63b80185050f837e37d27a136a03b13e1285e84a) Type AltGr characters into chat and search boxes on Windows ### 📊 Changes **7 files changed** (+55 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-input/src/clipboard.rs` (+29 -0) 📝 `crates/horizon-client/src/game/chat.rs` (+1 -1) 📝 `crates/horizon-client/src/game/clipboard.rs` (+16 -0) 📝 `crates/horizon-client/src/game/command_blocks.rs` (+2 -1) 📝 `crates/horizon-client/src/game/lan_screen.rs` (+3 -2) 📝 `crates/horizon-client/src/game/native_panel.rs` (+2 -1) 📝 `crates/horizon-client/src/game/recipe_book.rs` (+2 -1) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. Fixes #3001 ## What and why On Windows, Ctrl+Alt is AltGr: a layout's third-level characters arrive as text while a Control key is down. ABNT2 types `/` on Ctrl+Alt+Q, German types `@`, `{` and `[` that way, and Polish types its letters (`ą`, `ę`, ...). The chat box dropped all of these. `chat_key_code` only passed typed text on when no Control key was held (`typed_text && !ctrl`), so pressing Ctrl+Alt+Q with ABNT2 typed nothing. The same `!ctrl` gate sat in front of the command block's command field, the LAN world options' fields (port and game rules), the recipe book search and the mod item panel search. All of them now use one check, `clipboard::types_text`. Text is dropped only when the edit modifier (Ctrl, or Cmd on macOS) is held **without** Alt. Ctrl+A/C/V/X and other Ctrl shortcuts still type nothing. `ALTGR_IS_CTRL_ALT` is true on Windows only. Elsewhere AltGr is its own modifier and Control is never held for it, so Linux and macOS behave as before. Sign, book, anvil, title and creative-search input never had the gate and are unchanged. Root cause: winit hides the fake Control that a real AltGr key adds, but only when the layout reports AltGr and the right Alt follows at once. Ctrl+Alt pressed by hand (as on the reporter's US keyboard with the ABNT2 layout) is a real Control press. That press stayed in the held keys, and the `!ctrl` gate then dropped the character. ## Vanilla reference - `KeyboardHandler.textInput(long, String)` passes every code point to `charTyped(long, CharacterEvent)`. `CharacterEvent` carries only the code point, so no modifier check happens. - `EditBox.charTyped(CharacterEvent)` checks only `canConsumeInput()`, `CharacterEvent.isAllowedChatCharacter()` and `isEditable`, then calls `insertText`. Text that would not type in vanilla is still rejected the same way as before, by `type_text`/`insert_text`'s `isAllowedChatCharacter` filter. ## Tests New unit test `clipboard::tests::altgr_types_text_where_it_is_ctrl_alt` (horizon-client-input). Before (only the helper's body put back to the old rule, `!edit_modifier`): ``` test clipboard::tests::altgr_types_text_where_it_is_ctrl_alt ... FAILED thread 'clipboard::tests::altgr_types_text_where_it_is_ctrl_alt' panicked at crates\horizon-client-input\src\clipboard.rs:329:9: assertion failed: types_text(true, true, true) test result: FAILED. 6 passed; 1 failed ``` After: ``` running 7 tests test clipboard::tests::altgr_types_text_where_it_is_ctrl_alt ... ok ... test result: ok. 7 passed; 0 failed ``` ## In game (Windows 11) I opened chat in a fresh creative world. Then I posted Ctrl+Alt+Q to the game window five times, with the characters a layout gives for it (`/`, `@`, `{`, `[`, `ą`). Each time it got the left Control, the left Alt, Q and its WM_CHAR, with the thread's key state set to match, as for real input. I read the chat box through the control socket: - before (current main): `chat_input: ""`. Every character was swallowed. - after: `chat_input: "/@{[ą"`. The `/` also opens command suggestions, as typing `/` does. ## Self-check ``` cargo fmt --all -- --check # ok cargo clippy -p horizon-client-input --all-targets -- -D warnings # ok cargo clippy -p horizon-client --features mods --all-targets -- -D warnings # ok cargo test -p horizon-client-input --lib clipboard # 7 passed cargo build --profile fast -p horizon-client --features mods --bins # ok ``` (`tools/pr_ready.py` was not run: it doesn't run on Windows.) 🤖 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:10:32 +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#5142
No description provided.