| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 // This function is exported by chrome.exe. | 67 // This function is exported by chrome.exe. |
| 68 typedef int (__cdecl *BreakpadExceptionHandler)(EXCEPTION_POINTERS* info); | 68 typedef int (__cdecl *BreakpadExceptionHandler)(EXCEPTION_POINTERS* info); |
| 69 | 69 |
| 70 // Global information used across the metro driver. | 70 // Global information used across the metro driver. |
| 71 struct Globals { | 71 struct Globals { |
| 72 winapp::Activation::ApplicationExecutionState previous_state; | 72 winapp::Activation::ApplicationExecutionState previous_state; |
| 73 winapp::Core::ICoreApplicationExit* app_exit; | 73 winapp::Core::ICoreApplicationExit* app_exit; |
| 74 BreakpadExceptionHandler breakpad_exception_handler; | 74 BreakpadExceptionHandler breakpad_exception_handler; |
| 75 } globals; | 75 } globals; |
| 76 | 76 |
| 77 extern float GetModernUIScale(); |
| 78 |
| 77 namespace { | 79 namespace { |
| 78 | 80 |
| 79 enum KeyModifier { | 81 enum KeyModifier { |
| 80 NONE, | 82 NONE, |
| 81 SHIFT = 1, | 83 SHIFT = 1, |
| 82 CONTROL = 2, | 84 CONTROL = 2, |
| 83 ALT = 4 | 85 ALT = 4 |
| 84 }; | 86 }; |
| 85 | 87 |
| 86 // Helper function to send keystrokes via the SendInput function. | 88 // Helper function to send keystrokes via the SendInput function. |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 | 501 |
| 500 // Set to true for a horizontal wheel message. | 502 // Set to true for a horizontal wheel message. |
| 501 boolean is_horizontal_wheel_; | 503 boolean is_horizontal_wheel_; |
| 502 | 504 |
| 503 DISALLOW_COPY_AND_ASSIGN(PointerInfoHandler); | 505 DISALLOW_COPY_AND_ASSIGN(PointerInfoHandler); |
| 504 }; | 506 }; |
| 505 | 507 |
| 506 ChromeAppViewAsh::ChromeAppViewAsh() | 508 ChromeAppViewAsh::ChromeAppViewAsh() |
| 507 : mouse_down_flags_(ui::EF_NONE), | 509 : mouse_down_flags_(ui::EF_NONE), |
| 508 ui_channel_(nullptr), | 510 ui_channel_(nullptr), |
| 509 core_window_hwnd_(NULL) { | 511 core_window_hwnd_(NULL), |
| 512 scale_(0) { |
| 510 DVLOG(1) << __FUNCTION__; | 513 DVLOG(1) << __FUNCTION__; |
| 511 globals.previous_state = | 514 globals.previous_state = |
| 512 winapp::Activation::ApplicationExecutionState_NotRunning; | 515 winapp::Activation::ApplicationExecutionState_NotRunning; |
| 513 } | 516 } |
| 514 | 517 |
| 515 ChromeAppViewAsh::~ChromeAppViewAsh() { | 518 ChromeAppViewAsh::~ChromeAppViewAsh() { |
| 516 DVLOG(1) << __FUNCTION__; | 519 DVLOG(1) << __FUNCTION__; |
| 517 } | 520 } |
| 518 | 521 |
| 519 IFACEMETHODIMP | 522 IFACEMETHODIMP |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 hr = edge_gesture->add_Completed(mswr::Callback<EdgeEventHandler>( | 621 hr = edge_gesture->add_Completed(mswr::Callback<EdgeEventHandler>( |
| 619 this, &ChromeAppViewAsh::OnEdgeGestureCompleted).Get(), | 622 this, &ChromeAppViewAsh::OnEdgeGestureCompleted).Get(), |
| 620 &edgeevent_token_); | 623 &edgeevent_token_); |
| 621 CheckHR(hr); | 624 CheckHR(hr); |
| 622 } | 625 } |
| 623 | 626 |
| 624 // By initializing the direct 3D swap chain with the corewindow | 627 // By initializing the direct 3D swap chain with the corewindow |
| 625 // we can now directly blit to it from the browser process. | 628 // we can now directly blit to it from the browser process. |
| 626 direct3d_helper_.Initialize(window); | 629 direct3d_helper_.Initialize(window); |
| 627 DVLOG(1) << "Initialized Direct3D."; | 630 DVLOG(1) << "Initialized Direct3D."; |
| 631 |
| 632 scale_ = GetModernUIScale(); |
| 633 DVLOG(1) << "Scale is " << scale_; |
| 628 return S_OK; | 634 return S_OK; |
| 629 } | 635 } |
| 630 | 636 |
| 631 IFACEMETHODIMP | 637 IFACEMETHODIMP |
| 632 ChromeAppViewAsh::Load(HSTRING entryPoint) { | 638 ChromeAppViewAsh::Load(HSTRING entryPoint) { |
| 633 // On Win7 |entryPoint| is NULL. | 639 // On Win7 |entryPoint| is NULL. |
| 634 DVLOG(1) << __FUNCTION__; | 640 DVLOG(1) << __FUNCTION__; |
| 635 return S_OK; | 641 return S_OK; |
| 636 } | 642 } |
| 637 | 643 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 662 ChromeChannelListener ui_channel_listener(&ui_loop_, this); | 668 ChromeChannelListener ui_channel_listener(&ui_loop_, this); |
| 663 IPC::ChannelProxy ui_channel(win8::kMetroViewerIPCChannelName, | 669 IPC::ChannelProxy ui_channel(win8::kMetroViewerIPCChannelName, |
| 664 IPC::Channel::MODE_NAMED_CLIENT, | 670 IPC::Channel::MODE_NAMED_CLIENT, |
| 665 &ui_channel_listener, | 671 &ui_channel_listener, |
| 666 io_thread.message_loop_proxy()); | 672 io_thread.message_loop_proxy()); |
| 667 ui_channel_ = &ui_channel; | 673 ui_channel_ = &ui_channel; |
| 668 | 674 |
| 669 // Upon receipt of the MetroViewerHostMsg_SetTargetSurface message the | 675 // Upon receipt of the MetroViewerHostMsg_SetTargetSurface message the |
| 670 // browser will use D3D from the browser process to present to our Window. | 676 // browser will use D3D from the browser process to present to our Window. |
| 671 ui_channel_->Send(new MetroViewerHostMsg_SetTargetSurface( | 677 ui_channel_->Send(new MetroViewerHostMsg_SetTargetSurface( |
| 672 gfx::NativeViewId(core_window_hwnd_))); | 678 gfx::NativeViewId(core_window_hwnd_), scale_)); |
| 673 DVLOG(1) << "ICoreWindow sent " << core_window_hwnd_; | 679 DVLOG(1) << "ICoreWindow sent " << core_window_hwnd_; |
| 674 | 680 |
| 675 // Send an initial size message so that the Ash root window host gets sized | 681 // Send an initial size message so that the Ash root window host gets sized |
| 676 // correctly. | 682 // correctly. |
| 677 RECT rect = {0}; | 683 RECT rect = {0}; |
| 678 ::GetWindowRect(core_window_hwnd_, &rect); | 684 ::GetWindowRect(core_window_hwnd_, &rect); |
| 679 ui_channel_->Send( | 685 ui_channel_->Send( |
| 680 new MetroViewerHostMsg_WindowSizeChanged(rect.right - rect.left, | 686 new MetroViewerHostMsg_WindowSizeChanged(rect.right - rect.left, |
| 681 rect.bottom - rect.top)); | 687 rect.bottom - rect.top)); |
| 682 | 688 |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1350 mswr::ComPtr<winapp::Core::ICoreApplicationExit> app_exit; | 1356 mswr::ComPtr<winapp::Core::ICoreApplicationExit> app_exit; |
| 1351 CheckHR(core_app.As(&app_exit)); | 1357 CheckHR(core_app.As(&app_exit)); |
| 1352 globals.app_exit = app_exit.Detach(); | 1358 globals.app_exit = app_exit.Detach(); |
| 1353 } | 1359 } |
| 1354 | 1360 |
| 1355 IFACEMETHODIMP | 1361 IFACEMETHODIMP |
| 1356 ChromeAppViewFactory::CreateView(winapp::Core::IFrameworkView** view) { | 1362 ChromeAppViewFactory::CreateView(winapp::Core::IFrameworkView** view) { |
| 1357 *view = mswr::Make<ChromeAppViewAsh>().Detach(); | 1363 *view = mswr::Make<ChromeAppViewAsh>().Detach(); |
| 1358 return (*view) ? S_OK : E_OUTOFMEMORY; | 1364 return (*view) ? S_OK : E_OUTOFMEMORY; |
| 1359 } | 1365 } |
| OLD | NEW |