Skip to content

Commit

Permalink
fix(chord_composer): stop at super and caps by default
Browse files Browse the repository at this point in the history
Stop composing chord when a key event is super or caps modified, just like ctrl, alt, and shift.

Previously, super+any key will be consumed by rime when chord typing.
  • Loading branch information
ksqsf authored Feb 6, 2024
1 parent 6546689 commit 8709a7a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/rime/gear/chord_composer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ ChordComposer::ChordComposer(const Ticket& ticket) : Processor(ticket) {
config->GetBool("chord_composer/use_control", &use_control_);
config->GetBool("chord_composer/use_alt", &use_alt_);
config->GetBool("chord_composer/use_shift", &use_shift_);
config->GetBool("chord_composer/use_super", &use_super_);
config->GetBool("chord_composer/use_caps", &use_caps_);
config->GetString("speller/delimiter", &delimiter_);
algebra_.Load(config->GetList("chord_composer/algebra"));
output_format_.Load(config->GetList("chord_composer/output_format"));
Expand Down Expand Up @@ -81,11 +83,13 @@ inline static int get_base_layer_key_code(const KeyEvent& key_event) {
}

ProcessResult ChordComposer::ProcessChordingKey(const KeyEvent& key_event) {
if (key_event.ctrl() || key_event.alt()) {
if (key_event.ctrl() || key_event.alt() || key_event.super() ||
key_event.caps()) {
raw_sequence_.clear();
}
if ((key_event.ctrl() && !use_control_) || (key_event.alt() && !use_alt_) ||
(key_event.shift() && !use_shift_)) {
(key_event.shift() && !use_shift_) ||
(key_event.super() && !use_super_) || (key_event.caps() && !use_caps_)) {
ClearChord();
return kNoop;
}
Expand Down
2 changes: 2 additions & 0 deletions src/rime/gear/chord_composer.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class ChordComposer : public Processor {
bool use_control_ = false;
bool use_alt_ = false;
bool use_shift_ = false;
bool use_super_ = false;
bool use_caps_ = false;

set<int> pressed_;
set<int> chord_;
Expand Down

0 comments on commit 8709a7a

Please sign in to comment.