diff --git a/src/rime/gear/key_binding_processor.h b/src/rime/gear/key_binding_processor.h index 3649dd40b7..1f7c64ccb4 100644 --- a/src/rime/gear/key_binding_processor.h +++ b/src/rime/gear/key_binding_processor.h @@ -21,9 +21,10 @@ class KeyBindingProcessor { enum FallbackOptions { None = 0, - ShiftAsControl = (1 << 0), - IgnoreShift = (1 << 1), - All = ShiftAsControl | IgnoreShift, + AltAsControl = (1 << 0), + ShiftAsControl = (1 << 1), + IgnoreShift = (1 << 2), + All = AltAsControl | ShiftAsControl | IgnoreShift }; struct ActionDef { diff --git a/src/rime/gear/key_binding_processor_impl.h b/src/rime/gear/key_binding_processor_impl.h index e283770b14..bf28e9c3e2 100644 --- a/src/rime/gear/key_binding_processor_impl.h +++ b/src/rime/gear/key_binding_processor_impl.h @@ -21,11 +21,19 @@ ProcessResult KeyBindingProcessor::ProcessKeyEvent( return kAccepted; } // try to match the fallback options - if (key_event.ctrl() || key_event.alt()) { + if (key_event.ctrl() || key_event.super()) { return kNoop; } + if (key_event.alt() && (fallback_options & AltAsControl)) { + KeyEvent alt_as_control{ + key_event.keycode(), + (key_event.modifier() & ~kAltMask) | kControlMask}; + if (Accept(alt_as_control, ctx, keymap)) { + return kAccepted; + } + } if (key_event.shift()) { - if ((fallback_options & ShiftAsControl) != 0) { + if ((fallback_options & ShiftAsControl) && !key_event.alt()) { KeyEvent shift_as_control{ key_event.keycode(), (key_event.modifier() & ~kShiftMask) | kControlMask};