Repository navigation
core: Add altGraph to key modifiers - #2979
Conversation
Windows sets it when the key's character comes from the layout's AltGr
level (Control and Alt held, Right Alt down, the key translates), so a
listener can tell AltGr text from a Ctrl+Alt shortcut, as the DOM's
getModifierState("AltGraph") does. Shortcuts never name or match it.
Fixes #2936
Agent: rust-maintainer
|
Compat dependency: longbridge/nsh-compat#69 |
Agent: rust-maintainer Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
💡 Re-review of the Source. The name and meaning come from the DOM / W3C UI Events: Is it needed? Yes for #2936: an app's Problems to fix before merge
Verdict: the API shape is reasonable and has a clear source; fix 1 and 3 (and 2 or document it) before merging. Native Windows check (German AltGr+Q vs Ctrl+Alt+;) is still not done. |
#2979 added `alt_graph: false` to `synth.rs`, but that literal builds the GPUI platform's internal `input::Modifiers` (Windows-only path), which has no such field. Windows Clippy on main fails with E0560. This removes the stray line. Verification: only compiled on Windows CI (the path is `cfg(windows)`). 🤖 [Noop](https://huacnlee.github.io/noop) (rust-maintainer) · AI agent acting for @huacnlee 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…2990) ## Description #2979 gave the Windows test agent's key presses `alt_graph: false` (`agent.rs`), a field of the core's `keymap::Modifiers`, on the platform's own `input::Modifiers`, which has no such field. `nsh-platform-windows` no longer builds with `dev`, which compiles the test agent, so `nsh run` / `nsh test` on Windows fail from a checkout: ``` error[E0560]: struct `input::Modifiers` has no field named `alt_graph` --> crates\nsh-platform-windows\src\agent.rs:289:13 ``` `cargo clippy -p nsh-platform-windows` without features does not compile `agent.rs`, so it passes. The line goes: the platform's modifiers become the core's through `Modifiers::core()`, which already sets `alt_graph: false`. ## How to Test On Windows: - `cargo clippy -p nsh-platform-windows -p nsh-windows-host --all-targets --features nsh-platform-windows/dev`: it fails before this change and is clean after. - `cargo build -p nsh-cli -p nsh-windows-host`, then `./target/debug/nsh test examples/tasks/App.tsx --target windows` with steps on stdin (typing, keyboard presses through the agent): it runs. ## Checklist - [x] I have read the [CONTRIBUTING](../CONTRIBUTING.md) document and followed the guidelines. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…2988) Since #2979, `nsh-platform-windows` no longer compiles: ``` error[E0560]: struct `input::Modifiers` has no field named `alt_graph` --> crates\nsh-platform-windows\src\agent.rs:289:13 = note: all struct fields are already assigned ``` The test agent's `press_keys` builds the Windows platform's own `input::Modifiers` (shift / ctrl / alt / meta), which has no `alt_graph`; only the core `keymap::Modifiers` gained it, and `input::Modifiers::to_core` already fills it with `false`. #2979's own Windows check was skipped, so the error first showed on PR merge refs (e.g. #2980's Windows `check`, run 45214662517). This drops the stray field. Synthesized key presses carry no AltGr state, as before. ## Public API None. ## Verification Not compiled locally; the Windows `check` on this PR verifies the build.
Fixes #2936
On Windows, AltGr is sent as Left Control + Right Alt, so a key event typed with AltGr and a Ctrl+Alt shortcut both reported
controlandalt, with nothing to tell them apart.API
keymap::Modifiers::alt_graph: boolModifiers.altGraph: boolean(the DOM'sgetModifierState("AltGraph"))Only key events set it. Shortcuts never name or match it:
capture_keystrokeand the keymap keep usingModifiers::core()without it, so Ctrl+Alt bindings behave as before.Windows
keyboard.rssets it when Control and Alt are held,VK_RMENUis down and the key translates to a character with the actual keyboard state (ToUnicodeEx). Left Alt + Ctrl, or a key with no AltGr character, staysfalse. Other platforms reportfalse.Compat
Needs the nsh-compat PR that defaults unread modifier fields (link below) so the compat job builds.
Verification
cargo test -p nsh-js --lib,cargo test -p nsh-core --lib keymap,cargo checkfor Linux, TUI, Web and GPUI crates pass locally.🤖 Noop (rust-maintainer) · AI agent acting for @huacnlee