diff options
author | yusukes@chromium.org <yusukes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-06 07:55:36 +0000 |
---|---|---|
committer | yusukes@chromium.org <yusukes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-06 07:55:36 +0000 |
commit | d251a32425ce880db26d59871220f119cba81b9b (patch) | |
tree | 66d8c0897c2622d68e7f1dcd23f5533e1342018b /ash | |
parent | ffd0dea064ef6c8c623b95c7c941a3cd95bb561b (diff) | |
download | chromium_src-d251a32425ce880db26d59871220f119cba81b9b.zip chromium_src-d251a32425ce880db26d59871220f119cba81b9b.tar.gz chromium_src-d251a32425ce880db26d59871220f119cba81b9b.tar.bz2 |
Set correct event type to |accelerator| in AcceleratorDispatcher::Dispatch().
BUG=116907
TEST=manual, ran aura_shell_unittests
Review URL: http://codereview.chromium.org/9609017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125133 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/accelerators/accelerator_dispatcher_linux.cc | 2 | ||||
-rw-r--r-- | ash/accelerators/accelerator_dispatcher_win.cc | 4 | ||||
-rw-r--r-- | ash/accelerators/nested_dispatcher_controller_unittest.cc | 17 |
3 files changed, 19 insertions, 4 deletions
diff --git a/ash/accelerators/accelerator_dispatcher_linux.cc b/ash/accelerators/accelerator_dispatcher_linux.cc index bfa1056..a4b76c8 100644 --- a/ash/accelerators/accelerator_dispatcher_linux.cc +++ b/ash/accelerators/accelerator_dispatcher_linux.cc @@ -43,6 +43,8 @@ base::MessagePumpDispatcher::DispatchStatus AcceleratorDispatcher::Dispatch( if (accelerator_controller) { ui::Accelerator accelerator(ui::KeyboardCodeFromNative(xev), ui::EventFlagsFromNative(xev) & kModifierMask); + if (xev->type == KeyRelease) + accelerator.set_type(ui::ET_KEY_RELEASED); if (accelerator_controller->Process(accelerator)) return EVENT_PROCESSED; diff --git a/ash/accelerators/accelerator_dispatcher_win.cc b/ash/accelerators/accelerator_dispatcher_win.cc index acd4593..9a3f18d 100644 --- a/ash/accelerators/accelerator_dispatcher_win.cc +++ b/ash/accelerators/accelerator_dispatcher_win.cc @@ -30,12 +30,14 @@ bool AcceleratorDispatcher::Dispatch(const MSG& msg) { return aura::Env::GetInstance()->GetDispatcher()->Dispatch(msg); if (msg.message == WM_KEYDOWN || msg.message == WM_SYSKEYDOWN || - msg.message == WM_KEYUP || msg.message == WM_SYSKEYUP) { + msg.message == WM_KEYUP || msg.message == WM_SYSKEYUP) { ash::AcceleratorController* accelerator_controller = ash::Shell::GetInstance()->accelerator_controller(); if (accelerator_controller) { ui::Accelerator accelerator(ui::KeyboardCodeFromNative(msg), ui::EventFlagsFromNative(msg) & kModifierMask); + if (msg.message == WM_KEYUP || msg.message == WM_SYSKEYUP) + accelerator.set_type(ui::ET_KEY_RELEASED); if (accelerator_controller->Process(accelerator)) return true; accelerator.set_type(TranslatedKeyEvent(msg, false).type()); diff --git a/ash/accelerators/nested_dispatcher_controller_unittest.cc b/ash/accelerators/nested_dispatcher_controller_unittest.cc index 7f15968..c0a2e4f 100644 --- a/ash/accelerators/nested_dispatcher_controller_unittest.cc +++ b/ash/accelerators/nested_dispatcher_controller_unittest.cc @@ -79,11 +79,21 @@ class TestTarget : public ui::AcceleratorTarget { }; void DispatchKeyReleaseA() { + // Sending both keydown and keyup is necessary here because the accelerator + // manager only checks a keyup event following a keydown event. See + // ShouldHandle() in ui/base/accelerators/accelerator_manager.cc for details. #if defined(OS_WIN) - MSG native_event = { NULL, WM_KEYUP, ui::VKEY_A, 0 }; - ash::Shell::GetRootWindow()->PostNativeEvent(native_event); + MSG native_event_down = { NULL, WM_KEYDOWN, ui::VKEY_A, 0 }; + ash::Shell::GetRootWindow()->PostNativeEvent(native_event_down); + MSG native_event_up = { NULL, WM_KEYUP, ui::VKEY_A, 0 }; + ash::Shell::GetRootWindow()->PostNativeEvent(native_event_up); #elif defined(USE_X11) XEvent native_event; + ui::InitXKeyEventForTesting(ui::ET_KEY_PRESSED, + ui::VKEY_A, + 0, + &native_event); + ash::Shell::GetRootWindow()->PostNativeEvent(&native_event); ui::InitXKeyEventForTesting(ui::ET_KEY_RELEASED, ui::VKEY_A, 0, @@ -151,7 +161,8 @@ TEST_F(NestedDispatcherTest, AcceleratorsHandled) { aura::RootWindow* root_window = ash::Shell::GetInstance()->GetRootWindow(); ui::Accelerator accelerator(ui::VKEY_A, false, false, false); - accelerator.set_type(ui::ET_TRANSLATED_KEY_RELEASE); + accelerator.set_type(ui::ET_KEY_RELEASED); + // TODO(yusukes): Add a test for a ui::ET_TRANSLATED_KEY_RELEASE accelerator. TestTarget target; Shell::GetInstance()->accelerator_controller()->Register(accelerator, &target); |