Chromium Code Reviews| Index: ui/keyboard/keyboard_util.cc |
| diff --git a/ui/keyboard/keyboard_util.cc b/ui/keyboard/keyboard_util.cc |
| index c234127a9ac9b0b24e74b1cd4a714a3a682418c1..dcea9e4bb163984e4cfb31f0d040cf429b59f3ff 100644 |
| --- a/ui/keyboard/keyboard_util.cc |
| +++ b/ui/keyboard/keyboard_util.cc |
| @@ -18,7 +18,11 @@ |
| #include "ui/base/ime/input_method.h" |
| #include "ui/base/ime/text_input_client.h" |
| #include "ui/events/event_processor.h" |
| +#include "ui/events/event_utils.h" |
| +#include "ui/events/keycodes/dom3/dom_code.h" |
| +#include "ui/events/keycodes/dom3/dom_key.h" |
| #include "ui/events/keycodes/dom4/keycode_converter.h" |
| +#include "ui/events/keycodes/keyboard_code_conversion.h" |
| #include "ui/keyboard/keyboard_controller.h" |
| #include "ui/keyboard/keyboard_controller_proxy.h" |
| #include "ui/keyboard/keyboard_switches.h" |
| @@ -31,7 +35,8 @@ const char kKeyUp[] = "keyup"; |
| void SendProcessKeyEvent(ui::EventType type, |
| aura::WindowTreeHost* host) { |
| - ui::KeyEvent event(type, ui::VKEY_PROCESSKEY, ui::EF_NONE); |
| + ui::KeyEvent event(type, ui::VKEY_PROCESSKEY, ui::DomCode::NONE, ui::EF_NONE, |
| + ui::DomKey::PROCESS, 0, ui::EventTimeForNow()); |
| event.SetTranslated(true); |
| ui::EventDispatchDetails details = |
| host->event_processor()->OnEventFromSource(&event); |
| @@ -193,34 +198,54 @@ bool MoveCursor(int swipe_direction, |
| return false; |
| ui::KeyboardCode codex = ui::VKEY_UNKNOWN; |
| ui::KeyboardCode codey = ui::VKEY_UNKNOWN; |
| - if (swipe_direction & kCursorMoveRight) |
| + ui::DomCode domcodex = ui::DomCode::NONE; |
| + ui::DomCode domcodey = ui::DomCode::NONE; |
| + ui::DomKey domkeyx = ui::DomKey::NONE; |
| + ui::DomKey domkeyy = ui::DomKey::NONE; |
| + if (swipe_direction & kCursorMoveRight) { |
| codex = ui::VKEY_RIGHT; |
| - else if (swipe_direction & kCursorMoveLeft) |
| + domcodex = ui::DomCode::ARROW_RIGHT; |
| + domkeyx = ui::DomKey::ARROW_RIGHT; |
| + } else if (swipe_direction & kCursorMoveLeft) { |
| codex = ui::VKEY_LEFT; |
| + domcodex = ui::DomCode::ARROW_LEFT; |
| + domkeyx = ui::DomKey::ARROW_LEFT; |
| + } |
| - if (swipe_direction & kCursorMoveUp) |
| + if (swipe_direction & kCursorMoveUp) { |
| codey = ui::VKEY_UP; |
| - else if (swipe_direction & kCursorMoveDown) |
| + domcodey = ui::DomCode::ARROW_UP; |
| + domkeyy = ui::DomKey::ARROW_UP; |
| + } else if (swipe_direction & kCursorMoveDown) { |
| codey = ui::VKEY_DOWN; |
| + domcodey = ui::DomCode::ARROW_DOWN; |
| + domkeyy = ui::DomKey::ARROW_DOWN; |
| + } |
|
sadrul
2015/04/21 18:48:16
This seems a bit unfortunate. Is it possible to au
kpschoedel
2015/04/21 19:32:07
Done, using DomCode as the source of truth. In the
|
| // First deal with the x movement. |
| if (codex != ui::VKEY_UNKNOWN) { |
| - ui::KeyEvent press_event(ui::ET_KEY_PRESSED, codex, modifier_flags); |
| + ui::KeyEvent press_event(ui::ET_KEY_PRESSED, codex, domcodex, |
| + modifier_flags, domkeyx, 0, ui::EventTimeForNow()); |
| ui::EventDispatchDetails details = |
| host->event_processor()->OnEventFromSource(&press_event); |
| CHECK(!details.dispatcher_destroyed); |
| - ui::KeyEvent release_event(ui::ET_KEY_RELEASED, codex, modifier_flags); |
| + ui::KeyEvent release_event(ui::ET_KEY_RELEASED, codex, domcodex, |
| + modifier_flags, domkeyx, 0, |
| + ui::EventTimeForNow()); |
| details = host->event_processor()->OnEventFromSource(&release_event); |
| CHECK(!details.dispatcher_destroyed); |
| } |
| // Then deal with the y movement. |
| if (codey != ui::VKEY_UNKNOWN) { |
| - ui::KeyEvent press_event(ui::ET_KEY_PRESSED, codey, modifier_flags); |
| + ui::KeyEvent press_event(ui::ET_KEY_PRESSED, codey, domcodey, |
| + modifier_flags, domkeyy, 0, ui::EventTimeForNow()); |
| ui::EventDispatchDetails details = |
| host->event_processor()->OnEventFromSource(&press_event); |
| CHECK(!details.dispatcher_destroyed); |
| - ui::KeyEvent release_event(ui::ET_KEY_RELEASED, codey, modifier_flags); |
| + ui::KeyEvent release_event(ui::ET_KEY_RELEASED, codey, domcodey, |
| + modifier_flags, domkeyy, 0, |
| + ui::EventTimeForNow()); |
| details = host->event_processor()->OnEventFromSource(&release_event); |
| CHECK(!details.dispatcher_destroyed); |
| } |
| @@ -274,10 +299,16 @@ bool SendKeyEvent(const std::string type, |
| } |
| } |
| + ui::DomCode dom_code = ui::DomCode::NONE; |
| + if (!key_name.empty()) |
| + dom_code = ui::KeycodeConverter::CodeStringToDomCode(key_name.c_str()); |
| + if (dom_code == ui::DomCode::NONE) |
| + dom_code = ui::UsLayoutKeyboardCodeToDomCode(code); |
| + CHECK(dom_code != ui::DomCode::NONE); |
| ui::KeyEvent event( |
| event_type, |
| code, |
| - ui::KeycodeConverter::CodeStringToDomCode(key_name.c_str()), |
| + dom_code, |
| modifiers); |
|
kpschoedel
2015/04/21 19:32:07
Remark: if the virtual keyboard knows the intended
|
| ui::EventDispatchDetails details = |
| host->event_processor()->OnEventFromSource(&event); |