Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c7bad2b

Browse files
committedJan 4, 2024
alt_as_control
1 parent 72f833d commit c7bad2b

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed
 

‎src/rime/gear/key_binding_processor.h

+4-3
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

+9-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,18 @@ 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{key_event.keycode(),
29+
(key_event.modifier() & ~kAltMask) | kControlMask};
30+
if (Accept(alt_as_control, ctx, keymap)) {
31+
return kAccepted;
32+
}
33+
}
2734
if (key_event.shift()) {
28-
if ((fallback_options & ShiftAsControl) != 0) {
35+
if ((fallback_options & ShiftAsControl) && !key_event.alt()) {
2936
KeyEvent shift_as_control{
3037
key_event.keycode(),
3138
(key_event.modifier() & ~kShiftMask) | kControlMask};

0 commit comments

Comments
 (0)
Please sign in to comment.