Skip to content

fix(macos): clear NumericPad from simulated text keys and existing keypad, navigation, and function-key behavior - #23

Merged
rustdesk merged 3 commits into
rustdesk-org:masterfrom
fufesou:fix/macos-clear-numpad-flag-on-text-key
Sep 17, 2026
Merged

rustdesk merged 3 commits into
rustdesk-org:masterfrom
fufesou:fix/macos-clear-numpad-flag-on-text-key

Conversation

@fufesou

@fufesou fufesou commented Sep 17, 2026 •

Copy link
Copy Markdown

May fix rustdesk/rustdesk#16227

macOS 27.0, 14.5: CGEventFlags::CGEventFlagNumericPad is not cleared after pressing numbers on the numpad when NumLock is on.

macOS 12.7.6 does not have this issue.

On macOS 27.0, 14.5:

  1. Use the Spanish keyboard layout.
  2. NumLock on, click 0.
  3. Click ´, no output
  4. Click e, e is printed, not é

Still no crash in my tests, but maybe the same root cause.

Summary by CodeRabbit

  • Bug Fixes
    • Improved macOS text-key event handling by clearing the NumericPad flag where appropriate.
    • Preserved existing behavior for keypad, navigation, function, Return, and Tab keys.
    • Ensured other event flags remain unchanged.
  • Tests
    • Added coverage for NumericPad flag removal and preservation of other flags.

and existing keypad, navigation, and function-key behavior.

Refs rustdesk/rustdesk#16227

Signed-off-by: fufesou <linlong1266@gmail.com>
@coderabbitai

coderabbitai Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Warning

Review limit reached

Next included review available in 8 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: cb7429b5-80af-4c78-ac68-2e1526408d45

📥 Commits

Reviewing files that changed from the base of the PR and between 1398437 and 0023b17.

📒 Files selected for processing (1)
  • src/macos/simulate.rs

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 3c6c613b-f38a-40f2-887a-b80977cfbbcf

📥 Commits

Reviewing files that changed from the base of the PR and between 23e24dd and 1398437.

📒 Files selected for processing (1)
  • src/macos/simulate.rs

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The macOS simulation path removes the NumericPad flag from eligible text-key events. Key conversion paths use the normalization helper. Tests verify flag removal, flag preservation, and excluded key types.

Changes

macOS text-key normalization

Layer / File(s) Summary
Normalize text-key flags
src/macos/simulate.rs
Adds normalize_text_key_event for eligible ANSI and JIS text keys. The helper preserves other flags and excludes Return, Tab, keypad, navigation, and function keys.
Route and validate normalized events
src/macos/simulate.rs
Applies normalization to workaround, raw virtual-keycode, and mapped key-down paths. Tests cover key press and release events, preserved flags, and excluded key classes.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 13984

The macOS keyboard normalization change has no identified merge-blocking risk in the reviewed scope.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: clearing NumericPad from simulated text keys while preserving related macOS keyboard behavior.
Linked Issues check ✅ Passed The change addresses linked issue #16227. normalize_text_key_event removes only CGEventFlagNumericPad from text-key events for both key-down and key-up paths. The conversion code applies this norm…
Out of Scope Changes check ✅ Passed The reviewed change is limited to macOS keyboard event normalization and focused tests. The implementation and tests directly support dead-key handling and the reported NumericPad state problem in i…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@rustdesk

Copy link
Copy Markdown
Collaborator

P2: Avoid difference() here to preserve compatibility with older bitflags 1.x versions.

rdev depends on core-graphics = 0.22.3, which allows older bitflags 1.x versions. CGEventFlags::difference() was added in later bitflags 1.x releases, so downstream users with an older Cargo.lock may fail to compile this change even though RustDesk currently resolves bitflags to 1.3.2.

We can simply use subtraction instead:

event.set_flags(flags - CGEventFlags::CGEventFlagNumericPad);

Sub is supported by older bitflags 1.x versions and implements the same set-difference operation (self.bits & !other.bits). It also preserves unknown/system flag bits already present in flags, so it satisfies the reason for avoiding flags & !CGEventFlagNumericPad.

… bitflags 1.x

Signed-off-by: fufesou <linlong1266@gmail.com>
Signed-off-by: fufesou <linlong1266@gmail.com>
@rustdesk
rustdesk merged commit a361d86 into rustdesk-org:master Sep 17, 2026
1 check passed
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.

[macOS] All apps crash when typing a dead key

2 participants