Skip to content

Commit 18e8959

Browse files
committed
alt_as_control
1 parent 72f833d commit 18e8959

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/rime/gear/key_binding_processor.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ class KeyBindingProcessor {
2121

2222
enum FallbackOptions {
2323
None = 0,
24-
ShiftAsControl = (1 << 0),
25-
IgnoreShift = (1 << 1),
26-
All = ShiftAsControl | IgnoreShift,
24+
AltAsControl = (1 << 0),
25+
ShiftAsControl = (1 << 1),
26+
IgnoreShift = (1 << 2),
27+
All = AltAsControl | ShiftAsControl | IgnoreShift
2728
};
2829

2930
struct ActionDef {

src/rime/gear/key_binding_processor_impl.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,19 @@ ProcessResult KeyBindingProcessor<T, N>::ProcessKeyEvent(
2121
return kAccepted;
2222
}
2323
// try to match the fallback options
24-
if (key_event.ctrl() || key_event.alt()) {
24+
if (key_event.ctrl() || key_event.super()) {
2525
return kNoop;
2626
}
27+
if (key_event.alt() && (fallback_options & AltAsControl)) {
28+
KeyEvent alt_as_control{
29+
key_event.keycode(),
30+
(key_event.modifier() & ~kAltMask) | kControlMask};
31+
if (Accept(alt_as_control, ctx, keymap)) {
32+
return kAccepted;
33+
}
34+
}
2735
if (key_event.shift()) {
28-
if ((fallback_options & ShiftAsControl) != 0) {
36+
if ((fallback_options & ShiftAsControl) && !key_event.alt()) {
2937
KeyEvent shift_as_control{
3038
key_event.keycode(),
3139
(key_event.modifier() & ~kShiftMask) | kControlMask};

0 commit comments

Comments
 (0)