Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean: simplify macOS hotkey mapping code #1942

Merged

Conversation

shenlebantongying
Copy link
Collaborator

@shenlebantongying shenlebantongying commented Nov 12, 2024

Let's merge this in another day,

Chop related code to half.


This region of code looked scary because the first line assumes everyone uses English keyboard.

TISInputSourceRef inputSourceRef = TISCopyInputSourceForLanguage(CFSTR("en"));

So, the next line patches it by copying current input source -> TISCopyCurrentKeyboardInputSource

But japanese keyboard is slightly different, so it got patched again with TISCopyCurrentKeyboardLayoutInputSource

Just uses the last one TISCopyCurrentKeyboardLayoutInputSource, all code are no longer needed.


Also change mappping to a vector instead of calloc.

@shenlebantongying
Copy link
Collaborator Author

Don't think this will bring any regression, because the simplified code user the thing that handles goldendict/goldendict#1419

Also tested other situations -> chinese input method & English

@shenlebantongying shenlebantongying enabled auto-merge (squash) November 12, 2024 12:24
@shenlebantongying shenlebantongying merged commit 4539481 into xiaoyifang:staged Nov 12, 2024
8 checks passed
@shenlebantongying shenlebantongying deleted the clean/simp-mac-hotkeymap branch November 12, 2024 12:34
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.

1 participant