Skip to content

fix(windows): 修正 LeftOption 映射到左 Alt#382

Merged
H-Chris233 merged 3 commits into
Open-Less:betafrom
weikeyi:beta
May 9, 2026
Merged

fix(windows): 修正 LeftOption 映射到左 Alt#382
H-Chris233 merged 3 commits into
Open-Less:betafrom
weikeyi:beta

Conversation

@weikeyi
Copy link
Copy Markdown
Contributor

@weikeyi weikeyi commented May 9, 2026

User description

概要

修复 #225:Windows 上 LeftOption 不应匹配右 Alt / AltRight

本次修复包含两条路径:

  • 修正 window hotkey fallback:

    • LeftOption 匹配 AltLeft
    • LeftOption 不再匹配 AltRight
    • RightOption / RightAlt 仍匹配 AltRight
  • 修正 Windows low-level keyboard hook:

    • 新增 VK_LMENU
    • LeftOption 映射到 VK_LMENU
    • RightOption / RightAlt 保持映射到 VK_RMENU

同时补充回归测试,覆盖左右 Alt 不应互相串键。

Fixes #225.

原因

修复前,Windows 代码里存在历史折叠逻辑:

  • LeftOption 被复用到 RightAlt / VK_RMENU
  • window fallback 测试也把 LeftOption -> AltRight 当作正确行为

这导致用户选择 LeftOption 后,实际需要按右 Alt / AltGr 才会触发;按左 Alt 不触发。

修改内容

  • coordinator.rs

    • 将 window_key_matches_trigger(...) 中的 LeftOption fallback 从 AltRight 改为 AltLeft
    • 更新对应测试:
      • LeftOption + AltLeft 为正例
      • LeftOption + AltRight 为反例
  • hotkey.rs

    • 添加 VK_LMENU = 0xA4
    • 将 Windows low-level hook 中的 LeftOptionVK_RMENU 改为 VK_LMENU
    • 保持 RightOption / RightAlt 使用 VK_RMENU
    • 新增测试 windows_option_triggers_keep_left_and_right_alt_separate

PR Type

Bug fix, Tests


Description


Diagram Walkthrough

flowchart LR
  A["LeftOption trigger"] -- "before: matched AltRight/VK_RMENU" --> B["Right Alt key"]
  A -- "after: matched AltLeft/VK_LMENU" --> C["Left Alt key"]
  D["coordinator.rs"] -- "update tests" --> E["Verify LeftOption -> AltLeft"]
  F["hotkey.rs"] -- "add new test" --> G["Ensure LeftOption/RightOption separation"]
Loading

File Walkthrough

Relevant files
Bug fix
coordinator.rs
Fix LeftOption fallback to match AltLeft in window key matcher

openless-all/app/src-tauri/src/coordinator.rs

  • Corrected LeftOption matching from AltRight to AltLeft in
    window_key_matches_trigger
  • Updated test cases: positive case expects AltLeft; negative case now
    rejects AltRight
+3/-3     
hotkey.rs
Fix LeftOption virtual key mapping and add left/right Alt separation
tests

openless-all/app/src-tauri/src/hotkey.rs

  • Added VK_LMENU constant (0xA4)
  • Changed trigger_to_vk_code mapping for LeftOption from VK_RMENU to
    VK_LMENU
  • Updated windows_optional_modifier_shortcuts_use_independent_latches to
    use VK_LMENU
  • Added new test
    windows_option_triggers_keep_left_and_right_alt_separate verifying
    only correct virtual keys trigger each option
+48/-8   

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

PR Reviewer Guide 🔍

(Review updated until commit 941542c)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis ✅

225 - PR Code Verified

Compliant requirements:

  • LeftOption 只匹配 AltLeft.
  • RightOption / RightAlt 仍匹配 AltRight.
  • 增加测试防止左右 Alt 再次写反.

Requires further human verification:

  • Windows fallback 模式下 UI 选择的左右键与实际触发一致.
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

Persistent review updated to latest commit 9cdb58d

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

Persistent review updated to latest commit 941542c

@H-Chris233 H-Chris233 merged commit 9ccaf05 into Open-Less:beta May 9, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(windows): LeftOption fallback 不应匹配 AltRight

2 participants