Skip to content

fix(inject): match Lock Screen by character, not physical key position - #1464

Open
4ni1ak wants to merge 1 commit into
AprilNEA:masterfrom
4ni1ak:fix/lockscreen-azerty-keycode
Open

4ni1ak wants to merge 1 commit into
AprilNEA:masterfrom
4ni1ak:fix/lockscreen-azerty-keycode

Conversation

@4ni1ak

@4ni1ak 4ni1ak commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The Lock Screen action never worked on non-QWERTY layouts (reported on French AZERTY): it typed the wrong character and macOS ignored the chord.

Changes

  • crates/openlogi-inject/src/inject/macos.rs: macOS's Lock Screen shortcut (Ctrl+Cmd+Q) is matched by the resolved character, not the physical key position — confirmed by the reporter's own CGEventTap trace: posting the ANSI-QWERTY position of Q (kVK_ANSI_Q = 0x0C) types A on AZERTY and does nothing, while posting the ANSI-QWERTY position of A (kVK_ANSI_A = 0x00, which types Q on AZERTY) successfully locks. This is unlike Screenshot's Cmd+Shift+3, which macOS binds to the physical digit-row position regardless of layout. Added post_key_for_char, which sets the event's unicode payload directly via CGEventKeyboardSetUnicodeString (the same technique already used by post_unicode for TypeText) instead of relying on a fixed virtual keycode, and switched NativeAction::LockScreen to it.

Testing

  • cargo check -p openlogi-inject --target x86_64-apple-darwin
  • cargo clippy -p openlogi-inject --target x86_64-apple-darwin --all-targets -- -D warnings
  • cargo clippy --workspace --all-targets -- -D warnings (full tier; Linux host, macOS code only cross-checked above)
  • cargo test --workspace
  • RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items --exclude openlogi-ui --exclude openlogi-desktop --exclude openlogi-overlay --exclude openlogi-agent
  • Not runtime-tested on macOS hardware (no linker available on this Linux host for the macOS target) — the fix follows the exact mechanism the reporter's own diagnostics point to and reuses an existing, working layout-independent technique already in this file, but real-hardware verification on an AZERTY Mac is still needed.

Fixes #1430

macOS's Lock Screen shortcut (Ctrl+Cmd+Q) is matched by the resolved
character, not the physical key position the way Screenshot's
Cmd+Shift+3 is. Hardcoding kVK_ANSI_Q for it types the character at
that physical position on the active layout, which is 'A' on AZERTY,
so the shortcut never fires.

Fixes AprilNEA#1430
@4ni1ak
4ni1ak requested a review from AprilNEA as a code owner September 17, 2026 06:33
@greptile-apps

greptile-apps Bot commented Sep 17, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with no concrete correctness, security, or repository-rule violations identified.

Summary

This PR updates the macOS Lock Screen action to identify its Q key by resolved character rather than a fixed ANSI/QWERTY key position.

  • Adds post_key_for_char, which attaches a Unicode payload to synthesized key-down and key-up events.
  • Uses the new helper for Ctrl+Cmd+Q while leaving position-based shortcuts unchanged.

Reviews (1) · Last reviewed commit: "fix(inject): match Lock Screen by charac..."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: LockScreen uses the wrong keycode on AZERTY

1 participant