OLD | NEW |
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 <corewindow.h> | 8 #include <corewindow.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #include <windows.foundation.h> | 10 #include <windows.foundation.h> |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 typedef winfoundtn::ITypedEventHandler< | 43 typedef winfoundtn::ITypedEventHandler< |
44 winui::Core::CoreDispatcher*, | 44 winui::Core::CoreDispatcher*, |
45 winui::Core::AcceleratorKeyEventArgs*> AcceleratorKeyEventHandler; | 45 winui::Core::AcceleratorKeyEventArgs*> AcceleratorKeyEventHandler; |
46 | 46 |
47 typedef winfoundtn::ITypedEventHandler< | 47 typedef winfoundtn::ITypedEventHandler< |
48 winui::Core::CoreWindow*, | 48 winui::Core::CoreWindow*, |
49 winui::Core::CharacterReceivedEventArgs*> CharEventHandler; | 49 winui::Core::CharacterReceivedEventArgs*> CharEventHandler; |
50 | 50 |
51 typedef winfoundtn::ITypedEventHandler< | 51 typedef winfoundtn::ITypedEventHandler< |
52 winui::Core::CoreWindow*, | 52 winui::Core::CoreWindow*, |
53 winui::Core::VisibilityChangedEventArgs*> VisibilityChangedHandler; | |
54 | |
55 typedef winfoundtn::ITypedEventHandler< | |
56 winui::Core::CoreWindow*, | |
57 winui::Core::WindowActivatedEventArgs*> WindowActivatedHandler; | 53 winui::Core::WindowActivatedEventArgs*> WindowActivatedHandler; |
58 | 54 |
59 typedef winfoundtn::ITypedEventHandler< | 55 typedef winfoundtn::ITypedEventHandler< |
60 winui::Core::CoreWindow*, | 56 winui::Core::CoreWindow*, |
61 winui::Core::WindowSizeChangedEventArgs*> SizeChangedHandler; | 57 winui::Core::WindowSizeChangedEventArgs*> SizeChangedHandler; |
62 | 58 |
63 // This function is exported by chrome.exe. | 59 // This function is exported by chrome.exe. |
64 typedef int (__cdecl *BreakpadExceptionHandler)(EXCEPTION_POINTERS* info); | 60 typedef int (__cdecl *BreakpadExceptionHandler)(EXCEPTION_POINTERS* info); |
65 | 61 |
66 // Global information used across the metro driver. | 62 // Global information used across the metro driver. |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 hr = window_->add_PointerWheelChanged(mswr::Callback<PointerEventHandler>( | 411 hr = window_->add_PointerWheelChanged(mswr::Callback<PointerEventHandler>( |
416 this, &ChromeAppViewAsh::OnWheel).Get(), | 412 this, &ChromeAppViewAsh::OnWheel).Get(), |
417 &wheel_token_); | 413 &wheel_token_); |
418 CheckHR(hr); | 414 CheckHR(hr); |
419 | 415 |
420 hr = window_->add_CharacterReceived(mswr::Callback<CharEventHandler>( | 416 hr = window_->add_CharacterReceived(mswr::Callback<CharEventHandler>( |
421 this, &ChromeAppViewAsh::OnCharacterReceived).Get(), | 417 this, &ChromeAppViewAsh::OnCharacterReceived).Get(), |
422 &character_received_token_); | 418 &character_received_token_); |
423 CheckHR(hr); | 419 CheckHR(hr); |
424 | 420 |
425 hr = window_->add_VisibilityChanged(mswr::Callback<VisibilityChangedHandler>( | |
426 this, &ChromeAppViewAsh::OnVisibilityChanged).Get(), | |
427 &visibility_changed_token_); | |
428 CheckHR(hr); | |
429 | |
430 hr = window_->add_Activated(mswr::Callback<WindowActivatedHandler>( | 421 hr = window_->add_Activated(mswr::Callback<WindowActivatedHandler>( |
431 this, &ChromeAppViewAsh::OnWindowActivated).Get(), | 422 this, &ChromeAppViewAsh::OnWindowActivated).Get(), |
432 &window_activated_token_); | 423 &window_activated_token_); |
433 CheckHR(hr); | 424 CheckHR(hr); |
434 | 425 |
435 // By initializing the direct 3D swap chain with the corewindow | 426 // By initializing the direct 3D swap chain with the corewindow |
436 // we can now directly blit to it from the browser process. | 427 // we can now directly blit to it from the browser process. |
437 direct3d_helper_.Initialize(window); | 428 direct3d_helper_.Initialize(window); |
438 DVLOG(1) << "Initialized Direct3D."; | 429 DVLOG(1) << "Initialized Direct3D."; |
439 return S_OK; | 430 return S_OK; |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 if (FAILED(hr)) | 864 if (FAILED(hr)) |
874 return hr; | 865 return hr; |
875 | 866 |
876 ui_channel_->Send(new MetroViewerHostMsg_Character(char_code, | 867 ui_channel_->Send(new MetroViewerHostMsg_Character(char_code, |
877 status.RepeatCount, | 868 status.RepeatCount, |
878 status.ScanCode, | 869 status.ScanCode, |
879 GetKeyboardEventFlags())); | 870 GetKeyboardEventFlags())); |
880 return S_OK; | 871 return S_OK; |
881 } | 872 } |
882 | 873 |
883 HRESULT ChromeAppViewAsh::OnVisibilityChanged( | |
884 winui::Core::ICoreWindow* sender, | |
885 winui::Core::IVisibilityChangedEventArgs* args) { | |
886 boolean visible = false; | |
887 HRESULT hr = args->get_Visible(&visible); | |
888 if (FAILED(hr)) | |
889 return hr; | |
890 | |
891 ui_channel_->Send(new MetroViewerHostMsg_VisibilityChanged(!!visible)); | |
892 return S_OK; | |
893 } | |
894 | |
895 HRESULT ChromeAppViewAsh::OnWindowActivated( | 874 HRESULT ChromeAppViewAsh::OnWindowActivated( |
896 winui::Core::ICoreWindow* sender, | 875 winui::Core::ICoreWindow* sender, |
897 winui::Core::IWindowActivatedEventArgs* args) { | 876 winui::Core::IWindowActivatedEventArgs* args) { |
898 winui::Core::CoreWindowActivationState state; | 877 winui::Core::CoreWindowActivationState state; |
899 HRESULT hr = args->get_WindowActivationState(&state); | 878 HRESULT hr = args->get_WindowActivationState(&state); |
900 if (FAILED(hr)) | 879 if (FAILED(hr)) |
901 return hr; | 880 return hr; |
| 881 |
| 882 // Treat both full activation (Ash was reopened from the Start Screen or from |
| 883 // any other Metro entry point in Windows) and pointer activation (user |
| 884 // clicked back in Ash after using another app on another monitor) the same. |
| 885 if (state == winui::Core::CoreWindowActivationState_CodeActivated || |
| 886 state == winui::Core::CoreWindowActivationState_PointerActivated) { |
| 887 ui_channel_->Send(new MetroViewerHostMsg_WindowActivated()); |
| 888 } |
902 return S_OK; | 889 return S_OK; |
903 } | 890 } |
904 | 891 |
905 HRESULT ChromeAppViewAsh::HandleSearchRequest( | 892 HRESULT ChromeAppViewAsh::HandleSearchRequest( |
906 winapp::Activation::IActivatedEventArgs* args) { | 893 winapp::Activation::IActivatedEventArgs* args) { |
907 mswr::ComPtr<winapp::Activation::ISearchActivatedEventArgs> search_args; | 894 mswr::ComPtr<winapp::Activation::ISearchActivatedEventArgs> search_args; |
908 CheckHR(args->QueryInterface( | 895 CheckHR(args->QueryInterface( |
909 winapp::Activation::IID_ISearchActivatedEventArgs, &search_args)); | 896 winapp::Activation::IID_ISearchActivatedEventArgs, &search_args)); |
910 | 897 |
911 if (!ui_channel_) { | 898 if (!ui_channel_) { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 mswr::ComPtr<winapp::Core::ICoreApplicationExit> app_exit; | 976 mswr::ComPtr<winapp::Core::ICoreApplicationExit> app_exit; |
990 CheckHR(core_app.As(&app_exit)); | 977 CheckHR(core_app.As(&app_exit)); |
991 globals.app_exit = app_exit.Detach(); | 978 globals.app_exit = app_exit.Detach(); |
992 } | 979 } |
993 | 980 |
994 IFACEMETHODIMP | 981 IFACEMETHODIMP |
995 ChromeAppViewFactory::CreateView(winapp::Core::IFrameworkView** view) { | 982 ChromeAppViewFactory::CreateView(winapp::Core::IFrameworkView** view) { |
996 *view = mswr::Make<ChromeAppViewAsh>().Detach(); | 983 *view = mswr::Make<ChromeAppViewAsh>().Detach(); |
997 return (*view) ? S_OK : E_OUTOFMEMORY; | 984 return (*view) ? S_OK : E_OUTOFMEMORY; |
998 } | 985 } |
OLD | NEW |