Skip to content

Commit

Permalink
Revert "feat(selector): handle repeated key until release"
Browse files Browse the repository at this point in the history
This reverts commit 8d93e9f.

Some clients (eg. Squirrel) don't pass keyup events to the IME,
resulting in consecutive Left keys being unable to pass through.
  • Loading branch information
lotem committed Jan 30, 2023
1 parent a0fceab commit ef3ac04
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
23 changes: 5 additions & 18 deletions src/rime/gear/selector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,8 @@ inline static bool is_linear_layout(Context* ctx) {
}

ProcessResult Selector::ProcessKeyEvent(const KeyEvent& key_event) {
if (key_event.release()) {
last_key_ = 0;
key_repeat_ = 0;
if (key_event.release() || key_event.alt())
return kNoop;
}
if (key_event.alt() || key_event.super())
return kNoop;

Context* ctx = engine_->context();
if (ctx->composition().empty())
return kNoop;
Expand All @@ -139,18 +133,11 @@ ProcessResult Selector::ProcessKeyEvent(const KeyEvent& key_event) {
is_linear_layout(ctx) ? Linear : Stacked;
auto result = KeyBindingProcessor::ProcessKeyEvent(
key_event, ctx, text_orientation | candidate_list_layout);

int ch = key_event.keycode();
if (result != kNoop) {
if (last_key_ == ch) {
++key_repeat_;
} else {
last_key_ = ch;
key_repeat_ = 1;
}
return result;
}

int ch = key_event.keycode();
int index = -1;
const string& select_keys(engine_->schema()->select_keys());
if (!select_keys.empty() &&
Expand Down Expand Up @@ -223,9 +210,8 @@ bool Selector::PreviousCandidate(Context* ctx) {
return false;
int index = comp.back().selected_index;
if (index <= 0) {
// in case of linear layout, fall back to navigator;
// repeated key press should be handled by the same processor.
return !is_linear_layout(ctx) || key_repeat_ > 0;
// in case of linear layout, fall back to navigator
return !is_linear_layout(ctx);
}
comp.back().selected_index = index - 1;
comp.back().tags.insert("paging");
Expand Down Expand Up @@ -270,6 +256,7 @@ bool Selector::End(Context* ctx) {
return Home(ctx);
}


bool Selector::SelectCandidateAt(Context* ctx, int index) {
Composition& comp = ctx->composition();
if (comp.empty())
Expand Down
4 changes: 0 additions & 4 deletions src/rime/gear/selector.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ class Selector : public Processor, public KeyBindingProcessor<Selector, 4> {
Handler End;

bool SelectCandidateAt(Context* ctx, int index);

private:
int last_key_ = 0;
int key_repeat_ = 0;
};

} // namespace rime
Expand Down

0 comments on commit ef3ac04

Please sign in to comment.