diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-07 22:21:52 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-07 22:21:52 +0000 |
commit | 45a6846c2efb0b934e3baed72027cba4ec1751b9 (patch) | |
tree | eaeef11ca280c09f35e641038825c753d2ea94f4 /win8 | |
parent | 2450c2dc0d0e5335fe6d35a29d5a550b343c5e42 (diff) | |
download | chromium_src-45a6846c2efb0b934e3baed72027cba4ec1751b9.zip chromium_src-45a6846c2efb0b934e3baed72027cba4ec1751b9.tar.gz chromium_src-45a6846c2efb0b934e3baed72027cba4ec1751b9.tar.bz2 |
Ensure that menus put in Chrome ASH on Windows 8 are operatable using the keyboard.
When a menu is displayed we enter a nested message loop in the Chrome Browser. This loop
expects to receive native events for WM_KEYDOWN/WM_KEYUP/WM_CHAR, etc. In desktop AURA this
works well because the native events come in through the standard OS mechanism.
In ASH we send over fabricated keyboard events from the viewer process to the browser where
these are dispatched to the root window. This causes the secondary loop to never receive these
events.
Fix for now is to check if we are in a nested loop in the RemoteRootWindowHostWin IPC handlers
and post the corresponding native event back to the queue.
The other change in this CL is to add an event handler to listen for accelerator events in the viewer
process. This is necessary to receive keystrokes like Alt, etc. We send over the same keydown/keyup/character
IPC's when we receive this event.
BUG=180738
R=cpu
TBR=ben
TEST=Will look into an ash based test for this in a subsequent CL.
Review URL: https://codereview.chromium.org/12558008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186797 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'win8')
-rw-r--r-- | win8/metro_driver/chrome_app_view_ash.cc | 68 | ||||
-rw-r--r-- | win8/metro_driver/chrome_app_view_ash.h | 6 |
2 files changed, 74 insertions, 0 deletions
diff --git a/win8/metro_driver/chrome_app_view_ash.cc b/win8/metro_driver/chrome_app_view_ash.cc index d3c128d..56c9afb 100644 --- a/win8/metro_driver/chrome_app_view_ash.cc +++ b/win8/metro_driver/chrome_app_view_ash.cc @@ -37,6 +37,10 @@ typedef winfoundtn::ITypedEventHandler< winui::Core::KeyEventArgs*> KeyEventHandler; typedef winfoundtn::ITypedEventHandler< + winui::Core::CoreDispatcher*, + winui::Core::AcceleratorKeyEventArgs*> AcceleratorKeyEventHandler; + +typedef winfoundtn::ITypedEventHandler< winui::Core::CoreWindow*, winui::Core::CharacterReceivedEventArgs*> CharEventHandler; @@ -311,6 +315,21 @@ ChromeAppViewAsh::SetWindow(winui::Core::ICoreWindow* window) { &keyup_token_); CheckHR(hr); + mswr::ComPtr<winui::Core::ICoreDispatcher> dispatcher; + hr = window_->get_Dispatcher(&dispatcher); + CheckHR(hr, "Get Dispatcher failed."); + + mswr::ComPtr<winui::Core::ICoreAcceleratorKeys> accelerator_keys; + hr = dispatcher.CopyTo(__uuidof(winui::Core::ICoreAcceleratorKeys), + reinterpret_cast<void**>( + accelerator_keys.GetAddressOf())); + CheckHR(hr, "QI for ICoreAcceleratorKeys failed."); + hr = accelerator_keys->add_AcceleratorKeyActivated( + mswr::Callback<AcceleratorKeyEventHandler>( + this, &ChromeAppViewAsh::OnAcceleratorKeyDown).Get(), + &accel_keydown_token_); + CheckHR(hr); + hr = window_->add_PointerWheelChanged(mswr::Callback<PointerEventHandler>( this, &ChromeAppViewAsh::OnWheel).Get(), &wheel_token_); @@ -640,6 +659,55 @@ HRESULT ChromeAppViewAsh::OnKeyUp( return S_OK; } +HRESULT ChromeAppViewAsh::OnAcceleratorKeyDown( + winui::Core::ICoreDispatcher* sender, + winui::Core::IAcceleratorKeyEventArgs* args) { + winsys::VirtualKey virtual_key; + HRESULT hr = args->get_VirtualKey(&virtual_key); + if (FAILED(hr)) + return hr; + winui::Core::CorePhysicalKeyStatus status; + hr = args->get_KeyStatus(&status); + if (FAILED(hr)) + return hr; + + winui::Core::CoreAcceleratorKeyEventType event_type; + hr = args->get_EventType(&event_type); + if (FAILED(hr)) + return hr; + + // The AURA event handling code does not handle the system key down event for + // the Alt key if we pass in the flag EF_ALT_DOWN. + uint32 keyboard_flags = GetKeyboardEventFlags() & ~ui::EF_ALT_DOWN; + + switch (event_type) { + case winui::Core::CoreAcceleratorKeyEventType_SystemCharacter: + ui_channel_->Send(new MetroViewerHostMsg_Character(virtual_key, + status.RepeatCount, + status.ScanCode, + keyboard_flags)); + break; + + case winui::Core::CoreAcceleratorKeyEventType_SystemKeyDown: + ui_channel_->Send(new MetroViewerHostMsg_KeyDown(virtual_key, + status.RepeatCount, + status.ScanCode, + keyboard_flags)); + break; + + case winui::Core::CoreAcceleratorKeyEventType_SystemKeyUp: + ui_channel_->Send(new MetroViewerHostMsg_KeyUp(virtual_key, + status.RepeatCount, + status.ScanCode, + keyboard_flags)); + break; + + default: + break; + } + return S_OK; +} + HRESULT ChromeAppViewAsh::OnCharacterReceived( winui::Core::ICoreWindow* sender, winui::Core::ICharacterReceivedEventArgs* args) { diff --git a/win8/metro_driver/chrome_app_view_ash.h b/win8/metro_driver/chrome_app_view_ash.h index 9dd0e60..c13f757 100644 --- a/win8/metro_driver/chrome_app_view_ash.h +++ b/win8/metro_driver/chrome_app_view_ash.h @@ -86,6 +86,10 @@ class ChromeAppViewAsh HRESULT OnKeyUp(winui::Core::ICoreWindow* sender, winui::Core::IKeyEventArgs* args); + // Invoked for system keys like Alt, etc. + HRESULT OnAcceleratorKeyDown(winui::Core::ICoreDispatcher* sender, + winui::Core::IAcceleratorKeyEventArgs* args); + HRESULT OnCharacterReceived(winui::Core::ICoreWindow* sender, winui::Core::ICharacterReceivedEventArgs* args); @@ -103,6 +107,8 @@ class ChromeAppViewAsh EventRegistrationToken keyup_token_; EventRegistrationToken character_received_token_; EventRegistrationToken visibility_changed_token_; + EventRegistrationToken accel_keydown_token_; + EventRegistrationToken accel_keyup_token_; // Keep state about which button is currently down, if any, as PointerMoved // events do not contain that state, but Ash's MouseEvents need it. |