xiaoyifang / goldendict-ng

The Next Generation GoldenDict
https://xiaoyifang.github.io/goldendict-ng/
Other
1.71k stars 95 forks source link

clean: simplify macOS hotkey mapping code #1942

Closed shenlebantongying closed 1 week ago

shenlebantongying commented 1 week ago

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 commented 1 week ago

Don't think this will bring any regression, because the simplified code user the thing that handles https://github.com/goldendict/goldendict/pull/1419

Also tested other situations -> chinese input method & English

sonarcloud[bot] commented 1 week ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud