diff options
-rw-r--r-- | components/exo/keyboard.cc | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/components/exo/keyboard.cc b/components/exo/keyboard.cc index 89437e0..dc50522 100644 --- a/components/exo/keyboard.cc +++ b/components/exo/keyboard.cc @@ -52,12 +52,18 @@ void Keyboard::OnKeyEvent(ui::KeyEvent* event) { delegate_->OnKeyboardModifiers(modifier_flags_); } + // When IME ate a key event, it re-sends the event after masking |key_code| + // by VKEY_PROCESSKEY. Although such events can be used to track the key + // states, they should not be sent as unmasked key events. Otherwise they are + // handled in two places (IME and client) and cause undesired behavior. + bool consumed_by_ime = (event->key_code() == ui::VKEY_PROCESSKEY); + switch (event->type()) { case ui::ET_KEY_PRESSED: { auto it = std::find(pressed_keys_.begin(), pressed_keys_.end(), event->code()); if (it == pressed_keys_.end()) { - if (focus_) + if (focus_ && !consumed_by_ime) delegate_->OnKeyboardKey(event->time_stamp(), event->code(), true); pressed_keys_.push_back(event->code()); @@ -67,7 +73,7 @@ void Keyboard::OnKeyEvent(ui::KeyEvent* event) { auto it = std::find(pressed_keys_.begin(), pressed_keys_.end(), event->code()); if (it != pressed_keys_.end()) { - if (focus_) + if (focus_ && !consumed_by_ime) delegate_->OnKeyboardKey(event->time_stamp(), event->code(), false); pressed_keys_.erase(it); |