Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: win8/metro_driver/chrome_app_view_ash.cc

Issue 12558008: Ensure that menus put in Chrome ASH on Windows 8 are operatable using the keyboard. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « win8/metro_driver/chrome_app_view_ash.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "win8/metro_driver/stdafx.h" 5 #include "win8/metro_driver/stdafx.h"
6 #include "win8/metro_driver/chrome_app_view_ash.h" 6 #include "win8/metro_driver/chrome_app_view_ash.h"
7 7
8 #include <windows.foundation.h> 8 #include <windows.foundation.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 19 matching lines...) Expand all
30 30
31 typedef winfoundtn::ITypedEventHandler< 31 typedef winfoundtn::ITypedEventHandler<
32 winui::Core::CoreWindow*, 32 winui::Core::CoreWindow*,
33 winui::Core::PointerEventArgs*> PointerEventHandler; 33 winui::Core::PointerEventArgs*> PointerEventHandler;
34 34
35 typedef winfoundtn::ITypedEventHandler< 35 typedef winfoundtn::ITypedEventHandler<
36 winui::Core::CoreWindow*, 36 winui::Core::CoreWindow*,
37 winui::Core::KeyEventArgs*> KeyEventHandler; 37 winui::Core::KeyEventArgs*> KeyEventHandler;
38 38
39 typedef winfoundtn::ITypedEventHandler< 39 typedef winfoundtn::ITypedEventHandler<
40 winui::Core::CoreDispatcher*,
41 winui::Core::AcceleratorKeyEventArgs*> AcceleratorKeyEventHandler;
42
43 typedef winfoundtn::ITypedEventHandler<
40 winui::Core::CoreWindow*, 44 winui::Core::CoreWindow*,
41 winui::Core::CharacterReceivedEventArgs*> CharEventHandler; 45 winui::Core::CharacterReceivedEventArgs*> CharEventHandler;
42 46
43 typedef winfoundtn::ITypedEventHandler< 47 typedef winfoundtn::ITypedEventHandler<
44 winui::Core::CoreWindow*, 48 winui::Core::CoreWindow*,
45 winui::Core::VisibilityChangedEventArgs*> VisibilityChangedHandler; 49 winui::Core::VisibilityChangedEventArgs*> VisibilityChangedHandler;
46 50
47 // This function is exported by chrome.exe. 51 // This function is exported by chrome.exe.
48 typedef int (__cdecl *BreakpadExceptionHandler)(EXCEPTION_POINTERS* info); 52 typedef int (__cdecl *BreakpadExceptionHandler)(EXCEPTION_POINTERS* info);
49 53
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 hr = window_->add_KeyDown(mswr::Callback<KeyEventHandler>( 308 hr = window_->add_KeyDown(mswr::Callback<KeyEventHandler>(
305 this, &ChromeAppViewAsh::OnKeyDown).Get(), 309 this, &ChromeAppViewAsh::OnKeyDown).Get(),
306 &keydown_token_); 310 &keydown_token_);
307 CheckHR(hr); 311 CheckHR(hr);
308 312
309 hr = window_->add_KeyUp(mswr::Callback<KeyEventHandler>( 313 hr = window_->add_KeyUp(mswr::Callback<KeyEventHandler>(
310 this, &ChromeAppViewAsh::OnKeyUp).Get(), 314 this, &ChromeAppViewAsh::OnKeyUp).Get(),
311 &keyup_token_); 315 &keyup_token_);
312 CheckHR(hr); 316 CheckHR(hr);
313 317
318 mswr::ComPtr<winui::Core::ICoreDispatcher> dispatcher;
319 hr = window_->get_Dispatcher(&dispatcher);
320 CheckHR(hr, "Get Dispatcher failed.");
321
322 mswr::ComPtr<winui::Core::ICoreAcceleratorKeys> accelerator_keys;
323 hr = dispatcher.CopyTo(__uuidof(winui::Core::ICoreAcceleratorKeys),
324 reinterpret_cast<void**>(
325 accelerator_keys.GetAddressOf()));
326 CheckHR(hr, "QI for ICoreAcceleratorKeys failed.");
327 hr = accelerator_keys->add_AcceleratorKeyActivated(
328 mswr::Callback<AcceleratorKeyEventHandler>(
329 this, &ChromeAppViewAsh::OnAcceleratorKeyDown).Get(),
330 &accel_keydown_token_);
331 CheckHR(hr);
332
314 hr = window_->add_PointerWheelChanged(mswr::Callback<PointerEventHandler>( 333 hr = window_->add_PointerWheelChanged(mswr::Callback<PointerEventHandler>(
315 this, &ChromeAppViewAsh::OnWheel).Get(), 334 this, &ChromeAppViewAsh::OnWheel).Get(),
316 &wheel_token_); 335 &wheel_token_);
317 CheckHR(hr); 336 CheckHR(hr);
318 337
319 hr = window_->add_CharacterReceived(mswr::Callback<CharEventHandler>( 338 hr = window_->add_CharacterReceived(mswr::Callback<CharEventHandler>(
320 this, &ChromeAppViewAsh::OnCharacterReceived).Get(), 339 this, &ChromeAppViewAsh::OnCharacterReceived).Get(),
321 &character_received_token_); 340 &character_received_token_);
322 CheckHR(hr); 341 CheckHR(hr);
323 342
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 if (FAILED(hr)) 652 if (FAILED(hr))
634 return hr; 653 return hr;
635 654
636 ui_channel_->Send(new MetroViewerHostMsg_KeyUp(virtual_key, 655 ui_channel_->Send(new MetroViewerHostMsg_KeyUp(virtual_key,
637 status.RepeatCount, 656 status.RepeatCount,
638 status.ScanCode, 657 status.ScanCode,
639 GetKeyboardEventFlags())); 658 GetKeyboardEventFlags()));
640 return S_OK; 659 return S_OK;
641 } 660 }
642 661
662 HRESULT ChromeAppViewAsh::OnAcceleratorKeyDown(
663 winui::Core::ICoreDispatcher* sender,
664 winui::Core::IAcceleratorKeyEventArgs* args) {
665 winsys::VirtualKey virtual_key;
666 HRESULT hr = args->get_VirtualKey(&virtual_key);
667 if (FAILED(hr))
668 return hr;
669 winui::Core::CorePhysicalKeyStatus status;
670 hr = args->get_KeyStatus(&status);
671 if (FAILED(hr))
672 return hr;
673
674 winui::Core::CoreAcceleratorKeyEventType event_type;
675 hr = args->get_EventType(&event_type);
676 if (FAILED(hr))
677 return hr;
678
679 // The AURA event handling code does not handle the system key down event for
680 // the Alt key if we pass in the flag EF_ALT_DOWN.
681 uint32 keyboard_flags = GetKeyboardEventFlags() & ~ui::EF_ALT_DOWN;
682
683 switch (event_type) {
684 case winui::Core::CoreAcceleratorKeyEventType_SystemCharacter:
685 ui_channel_->Send(new MetroViewerHostMsg_Character(virtual_key,
686 status.RepeatCount,
687 status.ScanCode,
688 keyboard_flags));
689 break;
690
691 case winui::Core::CoreAcceleratorKeyEventType_SystemKeyDown:
692 ui_channel_->Send(new MetroViewerHostMsg_KeyDown(virtual_key,
693 status.RepeatCount,
694 status.ScanCode,
695 keyboard_flags));
696 break;
697
698 case winui::Core::CoreAcceleratorKeyEventType_SystemKeyUp:
699 ui_channel_->Send(new MetroViewerHostMsg_KeyUp(virtual_key,
700 status.RepeatCount,
701 status.ScanCode,
702 keyboard_flags));
703 break;
704
705 default:
706 break;
707 }
708 return S_OK;
709 }
710
643 HRESULT ChromeAppViewAsh::OnCharacterReceived( 711 HRESULT ChromeAppViewAsh::OnCharacterReceived(
644 winui::Core::ICoreWindow* sender, 712 winui::Core::ICoreWindow* sender,
645 winui::Core::ICharacterReceivedEventArgs* args) { 713 winui::Core::ICharacterReceivedEventArgs* args) {
646 unsigned int char_code = 0; 714 unsigned int char_code = 0;
647 HRESULT hr = args->get_KeyCode(&char_code); 715 HRESULT hr = args->get_KeyCode(&char_code);
648 if (FAILED(hr)) 716 if (FAILED(hr))
649 return hr; 717 return hr;
650 718
651 winui::Core::CorePhysicalKeyStatus status; 719 winui::Core::CorePhysicalKeyStatus status;
652 hr = args->get_KeyStatus(&status); 720 hr = args->get_KeyStatus(&status);
(...skipping 30 matching lines...) Expand all
683 mswr::ComPtr<winapp::Core::ICoreApplicationExit> app_exit; 751 mswr::ComPtr<winapp::Core::ICoreApplicationExit> app_exit;
684 CheckHR(core_app.As(&app_exit)); 752 CheckHR(core_app.As(&app_exit));
685 globals.app_exit = app_exit.Detach(); 753 globals.app_exit = app_exit.Detach();
686 } 754 }
687 755
688 IFACEMETHODIMP 756 IFACEMETHODIMP
689 ChromeAppViewFactory::CreateView(winapp::Core::IFrameworkView** view) { 757 ChromeAppViewFactory::CreateView(winapp::Core::IFrameworkView** view) {
690 *view = mswr::Make<ChromeAppViewAsh>().Detach(); 758 *view = mswr::Make<ChromeAppViewAsh>().Detach();
691 return (*view) ? S_OK : E_OUTOFMEMORY; 759 return (*view) ? S_OK : E_OUTOFMEMORY;
692 } 760 }
OLDNEW
« no previous file with comments | « win8/metro_driver/chrome_app_view_ash.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698