diff options
author | kinaba <kinaba@chromium.org> | 2016-03-23 05:59:29 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-23 13:00:47 +0000 |
commit | 450a0f89f4ced236c372889a50da7ce184c9f11a (patch) | |
tree | 3d2e41c5c99c8b788295f01164a24f6803e9d8b7 /components | |
parent | 62cc80409b326670a7faafb3db806451fa6cc812 (diff) | |
download | chromium_src-450a0f89f4ced236c372889a50da7ce184c9f11a.zip chromium_src-450a0f89f4ced236c372889a50da7ce184c9f11a.tar.gz chromium_src-450a0f89f4ced236c372889a50da7ce184c9f11a.tar.bz2 |
exo: Do not send the key event already consumed by the system IME.
When a key event is filtered by IME, its key_code() is masked by VKEY_PROCESSKEY
but code() is kept as-is. Such a filtered key event should not be sent to the
client in unmasked form. Otherwise the event is double-handled.
BUG=597197
Review URL: https://codereview.chromium.org/1828643002
Cr-Commit-Position: refs/heads/master@{#382839}
Diffstat (limited to 'components')
-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); |