| 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 <windows.foundation.h> | 9 #include <windows.foundation.h> |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 winui::Core::CharacterReceivedEventArgs*> CharEventHandler; | 47 winui::Core::CharacterReceivedEventArgs*> CharEventHandler; |
| 48 | 48 |
| 49 typedef winfoundtn::ITypedEventHandler< | 49 typedef winfoundtn::ITypedEventHandler< |
| 50 winui::Core::CoreWindow*, | 50 winui::Core::CoreWindow*, |
| 51 winui::Core::VisibilityChangedEventArgs*> VisibilityChangedHandler; | 51 winui::Core::VisibilityChangedEventArgs*> VisibilityChangedHandler; |
| 52 | 52 |
| 53 typedef winfoundtn::ITypedEventHandler< | 53 typedef winfoundtn::ITypedEventHandler< |
| 54 winui::Core::CoreWindow*, | 54 winui::Core::CoreWindow*, |
| 55 winui::Core::WindowActivatedEventArgs*> WindowActivatedHandler; | 55 winui::Core::WindowActivatedEventArgs*> WindowActivatedHandler; |
| 56 | 56 |
| 57 typedef winfoundtn::ITypedEventHandler< |
| 58 winui::Core::CoreWindow*, |
| 59 winui::Core::WindowSizeChangedEventArgs*> SizeChangedHandler; |
| 60 |
| 57 // This function is exported by chrome.exe. | 61 // This function is exported by chrome.exe. |
| 58 typedef int (__cdecl *BreakpadExceptionHandler)(EXCEPTION_POINTERS* info); | 62 typedef int (__cdecl *BreakpadExceptionHandler)(EXCEPTION_POINTERS* info); |
| 59 | 63 |
| 60 // Global information used across the metro driver. | 64 // Global information used across the metro driver. |
| 61 struct Globals { | 65 struct Globals { |
| 62 winapp::Activation::ApplicationExecutionState previous_state; | 66 winapp::Activation::ApplicationExecutionState previous_state; |
| 63 winapp::Core::ICoreApplicationExit* app_exit; | 67 winapp::Core::ICoreApplicationExit* app_exit; |
| 64 BreakpadExceptionHandler breakpad_exception_handler; | 68 BreakpadExceptionHandler breakpad_exception_handler; |
| 65 } globals; | 69 } globals; |
| 66 | 70 |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 window_ = window; | 323 window_ = window; |
| 320 DVLOG(1) << __FUNCTION__; | 324 DVLOG(1) << __FUNCTION__; |
| 321 | 325 |
| 322 // Retrieve the native window handle via the interop layer. | 326 // Retrieve the native window handle via the interop layer. |
| 323 mswr::ComPtr<ICoreWindowInterop> interop; | 327 mswr::ComPtr<ICoreWindowInterop> interop; |
| 324 HRESULT hr = window->QueryInterface(interop.GetAddressOf()); | 328 HRESULT hr = window->QueryInterface(interop.GetAddressOf()); |
| 325 CheckHR(hr); | 329 CheckHR(hr); |
| 326 hr = interop->get_WindowHandle(&core_window_hwnd_); | 330 hr = interop->get_WindowHandle(&core_window_hwnd_); |
| 327 CheckHR(hr); | 331 CheckHR(hr); |
| 328 | 332 |
| 333 hr = window_->add_SizeChanged(mswr::Callback<SizeChangedHandler>( |
| 334 this, &ChromeAppViewAsh::OnSizeChanged).Get(), |
| 335 &sizechange_token_); |
| 336 CheckHR(hr); |
| 337 |
| 329 // Register for pointer and keyboard notifications. We forward | 338 // Register for pointer and keyboard notifications. We forward |
| 330 // them to the browser process via IPC. | 339 // them to the browser process via IPC. |
| 331 hr = window_->add_PointerMoved(mswr::Callback<PointerEventHandler>( | 340 hr = window_->add_PointerMoved(mswr::Callback<PointerEventHandler>( |
| 332 this, &ChromeAppViewAsh::OnPointerMoved).Get(), | 341 this, &ChromeAppViewAsh::OnPointerMoved).Get(), |
| 333 &pointermoved_token_); | 342 &pointermoved_token_); |
| 334 CheckHR(hr); | 343 CheckHR(hr); |
| 335 | 344 |
| 336 hr = window_->add_PointerPressed(mswr::Callback<PointerEventHandler>( | 345 hr = window_->add_PointerPressed(mswr::Callback<PointerEventHandler>( |
| 337 this, &ChromeAppViewAsh::OnPointerPressed).Get(), | 346 this, &ChromeAppViewAsh::OnPointerPressed).Get(), |
| 338 &pointerpressed_token_); | 347 &pointerpressed_token_); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 &ui_channel_listener, | 450 &ui_channel_listener, |
| 442 io_thread.message_loop_proxy()); | 451 io_thread.message_loop_proxy()); |
| 443 ui_channel_ = &ui_channel; | 452 ui_channel_ = &ui_channel; |
| 444 | 453 |
| 445 // Upon receipt of the MetroViewerHostMsg_SetTargetSurface message the | 454 // Upon receipt of the MetroViewerHostMsg_SetTargetSurface message the |
| 446 // browser will use D3D from the browser process to present to our Window. | 455 // browser will use D3D from the browser process to present to our Window. |
| 447 ui_channel_->Send(new MetroViewerHostMsg_SetTargetSurface( | 456 ui_channel_->Send(new MetroViewerHostMsg_SetTargetSurface( |
| 448 gfx::NativeViewId(core_window_hwnd_))); | 457 gfx::NativeViewId(core_window_hwnd_))); |
| 449 DVLOG(1) << "ICoreWindow sent " << core_window_hwnd_; | 458 DVLOG(1) << "ICoreWindow sent " << core_window_hwnd_; |
| 450 | 459 |
| 460 // Send an initial size message so that the Ash root window host gets sized |
| 461 // correctly. |
| 462 RECT rect = {0}; |
| 463 ::GetWindowRect(core_window_hwnd_, &rect); |
| 464 ui_channel_->Send( |
| 465 new MetroViewerHostMsg_WindowSizeChanged(rect.right - rect.left, |
| 466 rect.bottom - rect.top)); |
| 467 |
| 451 // And post the task that'll do the inner Metro message pumping to it. | 468 // And post the task that'll do the inner Metro message pumping to it. |
| 452 msg_loop.PostTask(FROM_HERE, base::Bind(&RunMessageLoop, dispatcher.Get())); | 469 msg_loop.PostTask(FROM_HERE, base::Bind(&RunMessageLoop, dispatcher.Get())); |
| 453 msg_loop.Run(); | 470 msg_loop.Run(); |
| 454 | 471 |
| 455 DVLOG(0) << "ProcessEvents done, hr=" << hr; | 472 DVLOG(0) << "ProcessEvents done, hr=" << hr; |
| 456 return hr; | 473 return hr; |
| 457 } | 474 } |
| 458 | 475 |
| 459 IFACEMETHODIMP | 476 IFACEMETHODIMP |
| 460 ChromeAppViewAsh::Uninitialize() { | 477 ChromeAppViewAsh::Uninitialize() { |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 winui::Core::CoreWindowActivationState state; | 840 winui::Core::CoreWindowActivationState state; |
| 824 HRESULT hr = args->get_WindowActivationState(&state); | 841 HRESULT hr = args->get_WindowActivationState(&state); |
| 825 if (FAILED(hr)) | 842 if (FAILED(hr)) |
| 826 return hr; | 843 return hr; |
| 827 DVLOG(1) << "Window activation state: " << state; | 844 DVLOG(1) << "Window activation state: " << state; |
| 828 ui_channel_->Send(new MetroViewerHostMsg_WindowActivated( | 845 ui_channel_->Send(new MetroViewerHostMsg_WindowActivated( |
| 829 state != winui::Core::CoreWindowActivationState_Deactivated)); | 846 state != winui::Core::CoreWindowActivationState_Deactivated)); |
| 830 return S_OK; | 847 return S_OK; |
| 831 } | 848 } |
| 832 | 849 |
| 850 HRESULT ChromeAppViewAsh::OnSizeChanged(winui::Core::ICoreWindow* sender, |
| 851 winui::Core::IWindowSizeChangedEventArgs* args) { |
| 852 if (!window_) { |
| 853 return S_OK; |
| 854 } |
| 855 |
| 856 winfoundtn::Size size; |
| 857 HRESULT hr = args->get_Size(&size); |
| 858 if (FAILED(hr)) |
| 859 return hr; |
| 860 |
| 861 uint32 cx = static_cast<uint32>(size.Width); |
| 862 uint32 cy = static_cast<uint32>(size.Height); |
| 863 |
| 864 DVLOG(1) << "Window size changed: width=" << cx << ", height=" << cy; |
| 865 ui_channel_->Send(new MetroViewerHostMsg_WindowSizeChanged(cx, cy)); |
| 866 return S_OK; |
| 867 } |
| 868 |
| 833 | 869 |
| 834 /////////////////////////////////////////////////////////////////////////////// | 870 /////////////////////////////////////////////////////////////////////////////// |
| 835 | 871 |
| 836 ChromeAppViewFactory::ChromeAppViewFactory( | 872 ChromeAppViewFactory::ChromeAppViewFactory( |
| 837 winapp::Core::ICoreApplication* icore_app, | 873 winapp::Core::ICoreApplication* icore_app, |
| 838 LPTHREAD_START_ROUTINE host_main, | 874 LPTHREAD_START_ROUTINE host_main, |
| 839 void* host_context) { | 875 void* host_context) { |
| 840 mswr::ComPtr<winapp::Core::ICoreApplication> core_app(icore_app); | 876 mswr::ComPtr<winapp::Core::ICoreApplication> core_app(icore_app); |
| 841 mswr::ComPtr<winapp::Core::ICoreApplicationExit> app_exit; | 877 mswr::ComPtr<winapp::Core::ICoreApplicationExit> app_exit; |
| 842 CheckHR(core_app.As(&app_exit)); | 878 CheckHR(core_app.As(&app_exit)); |
| 843 globals.app_exit = app_exit.Detach(); | 879 globals.app_exit = app_exit.Detach(); |
| 844 } | 880 } |
| 845 | 881 |
| 846 IFACEMETHODIMP | 882 IFACEMETHODIMP |
| 847 ChromeAppViewFactory::CreateView(winapp::Core::IFrameworkView** view) { | 883 ChromeAppViewFactory::CreateView(winapp::Core::IFrameworkView** view) { |
| 848 *view = mswr::Make<ChromeAppViewAsh>().Detach(); | 884 *view = mswr::Make<ChromeAppViewAsh>().Detach(); |
| 849 return (*view) ? S_OK : E_OUTOFMEMORY; | 885 return (*view) ? S_OK : E_OUTOFMEMORY; |
| 850 } | 886 } |
| OLD | NEW |