summaryrefslogtreecommitdiffstats
path: root/win8
diff options
context:
space:
mode:
authorcpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-21 11:39:08 +0000
committercpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-21 11:39:08 +0000
commitca1d1192fd4bf482a04fb725a4291cc124dde588 (patch)
tree09ed29c542a36e5e9a58af8898a08796b1471d77 /win8
parent35fad2692b6c3ae10c1a0c0831291a1a6433bca5 (diff)
downloadchromium_src-ca1d1192fd4bf482a04fb725a4291cc124dde588.zip
chromium_src-ca1d1192fd4bf482a04fb725a4291cc124dde588.tar.gz
chromium_src-ca1d1192fd4bf482a04fb725a4291cc124dde588.tar.bz2
Chrome metro mode win7 emulation.
It seems possible that we can run Ash (chrome metro) in Windows7 since we are using the GPU-direct path in Aura. In fact, we had something close to this that bitrotted because only the output (display) had common code with what we shipped but no commonality otherwise in two important regards - Input - Focus & Activation. Basically what we had it was a frankenstein between Ash and Desktop Aura that had the worst bugs from both and nobody cared to fix because a fix there would be mostly orthogonal from the two modes that we ship. This is an effort to address these issues. It uses COM / WinRT magic to try to reuse as much code as possible from the metro_viewer side, while trying to keep the browser side identical. In other to have that reuse, we need to emulate the host (microsoft) side of the metro environment. This patch is a start on that direction namely an emulation of a WinRT object known as "Windows.ApplicationModel.Core.CoreApplication" Which exposes a bunch of interfaces but only two we try to emulate. BUG=none Review URL: https://codereview.chromium.org/199843004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258530 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'win8')
-rw-r--r--win8/metro_driver/metro_driver.cc66
-rw-r--r--win8/metro_driver/metro_driver.gyp7
-rw-r--r--win8/metro_driver/metro_driver_win7.cc601
3 files changed, 554 insertions, 120 deletions
diff --git a/win8/metro_driver/metro_driver.cc b/win8/metro_driver/metro_driver.cc
index eb87754..a60af6b 100644
--- a/win8/metro_driver/metro_driver.cc
+++ b/win8/metro_driver/metro_driver.cc
@@ -13,11 +13,9 @@
#include "base/logging.h"
#include "base/logging_win.h"
#include "base/win/scoped_comptr.h"
+#include "base/win/windows_version.h"
#include "win8/metro_driver/winrt_utils.h"
-// TODO(siggi): Move this to GYP.
-#pragma comment(lib, "runtimeobject.lib")
-
namespace {
LONG WINAPI ErrorReportingHandler(EXCEPTION_POINTERS* ex_info) {
@@ -37,6 +35,17 @@ LONG WINAPI ErrorReportingHandler(EXCEPTION_POINTERS* ex_info) {
return EXCEPTION_CONTINUE_SEARCH;
}
+void SetMetroReportingFlags() {
+#if !defined(NDEBUG)
+ // Set the error reporting flags to always raise an exception,
+ // which is then processed by our vectored exception handling
+ // above to log the error message.
+ winfoundtn::Diagnostics::SetErrorReportingFlags(
+ winfoundtn::Diagnostics::UseSetErrorInfo |
+ winfoundtn::Diagnostics::ForceExceptions);
+#endif
+}
+
// TODO(robertshield): This GUID is hard-coded in a bunch of places that
// don't allow explicit includes. Find a single place for it to live.
// {7FE69228-633E-4f06-80C1-527FEA23E3A7}
@@ -44,7 +53,7 @@ const GUID kChromeTraceProviderName = {
0x7fe69228, 0x633e, 0x4f06,
{ 0x80, 0xc1, 0x52, 0x7f, 0xea, 0x23, 0xe3, 0xa7 } };
-}
+} // namespace
#if !defined(COMPONENT_BUILD)
// Required for base initialization.
@@ -54,53 +63,58 @@ const GUID kChromeTraceProviderName = {
base::AtExitManager at_exit;
#endif
+mswr::ComPtr<winapp::Core::ICoreApplication> InitWindows8() {
+ SetMetroReportingFlags();
+ HRESULT hr = ::Windows::Foundation::Initialize(RO_INIT_MULTITHREADED);
+ if (FAILED(hr))
+ CHECK(false);
+ mswr::ComPtr<winapp::Core::ICoreApplication> core_app;
+ hr = winrt_utils::CreateActivationFactory(
+ RuntimeClass_Windows_ApplicationModel_Core_CoreApplication,
+ core_app.GetAddressOf());
+ if (FAILED(hr))
+ CHECK(false);
+ return core_app;
+}
+
+mswr::ComPtr<winapp::Core::ICoreApplication> InitWindows7();
+
extern "C" __declspec(dllexport)
int InitMetro() {
+ // Metro mode or its emulation is not supported in Vista or XP.
+ if (base::win::GetVersion() < base::win::VERSION_WIN7)
+ return 1;
// Initialize the command line.
CommandLine::Init(0, NULL);
+ // Initialize the logging system.
logging::LoggingSettings settings;
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
logging::InitLogging(settings);
-
#if defined(NDEBUG)
logging::SetMinLogLevel(logging::LOG_ERROR);
#else
logging::SetMinLogLevel(logging::LOG_VERBOSE);
- // Set the error reporting flags to always raise an exception,
- // which is then processed by our vectored exception handling
- // above to log the error message.
- winfoundtn::Diagnostics::SetErrorReportingFlags(
- winfoundtn::Diagnostics::UseSetErrorInfo |
- winfoundtn::Diagnostics::ForceExceptions);
-
- HANDLE registration =
+ HANDLE registration =
::AddVectoredExceptionHandler(TRUE, ErrorReportingHandler);
#endif
-
// Enable trace control and transport through event tracing for Windows.
logging::LogEventProvider::Initialize(kChromeTraceProviderName);
-
DVLOG(1) << "InitMetro";
- mswrw::RoInitializeWrapper ro_initializer(RO_INIT_MULTITHREADED);
- CheckHR(ro_initializer, "RoInitialize failed");
-
+ // OS specific initialization.
mswr::ComPtr<winapp::Core::ICoreApplication> core_app;
- HRESULT hr = winrt_utils::CreateActivationFactory(
- RuntimeClass_Windows_ApplicationModel_Core_CoreApplication,
- core_app.GetAddressOf());
- CheckHR(hr, "Failed to create app factory");
- if (FAILED(hr))
- return 1;
+ if (base::win::GetVersion() < base::win::VERSION_WIN8)
+ core_app = InitWindows7();
+ else
+ core_app = InitWindows8();
auto view_factory = mswr::Make<ChromeAppViewFactory>(core_app.Get());
- hr = core_app->Run(view_factory.Get());
+ HRESULT hr = core_app->Run(view_factory.Get());
DVLOG(1) << "exiting InitMetro, hr=" << hr;
#if !defined(NDEBUG)
::RemoveVectoredExceptionHandler(registration);
#endif
-
return hr;
}
diff --git a/win8/metro_driver/metro_driver.gyp b/win8/metro_driver/metro_driver.gyp
index 42fd9c7..34fbcdd 100644
--- a/win8/metro_driver/metro_driver.gyp
+++ b/win8/metro_driver/metro_driver.gyp
@@ -22,6 +22,12 @@
'AdditionalDependencies': [
'D2D1.lib',
'D3D11.lib',
+ 'runtimeobject.lib',
+ ],
+ 'DelayLoadDLLs': [
+ 'API-MS-WIN-CORE-WINRT-ERROR-L1-1-0.DLL',
+ 'API-MS-WIN-CORE-WINRT-L1-1-0.DLL',
+ 'API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLL',
],
},
'VCCLCompilerTool': {
@@ -76,6 +82,7 @@
'display_properties.h',
'metro_driver.cc',
'metro_driver.h',
+ 'metro_driver_win7.cc',
'stdafx.h',
'winrt_utils.cc',
'winrt_utils.h',
diff --git a/win8/metro_driver/metro_driver_win7.cc b/win8/metro_driver/metro_driver_win7.cc
index 253e527..56d6c05 100644
--- a/win8/metro_driver/metro_driver_win7.cc
+++ b/win8/metro_driver/metro_driver_win7.cc
@@ -3,41 +3,11 @@
// found in the LICENSE file.
#include "stdafx.h"
+#include <corewindow.h>
-EXTERN_C IMAGE_DOS_HEADER __ImageBase;
+#include "base/logging.h"
-struct Globals {
- LPTHREAD_START_ROUTINE host_main;
- void* host_context;
- HWND core_window;
- HWND host_window;
- HANDLE host_thread;
- DWORD main_thread_id;
-} globals;
-
-
-void ODS(const char* str, LONG_PTR val = 0) {
- char buf[80];
- size_t len = strlen(str);
- if (len > 50) {
- ::OutputDebugStringA("ODS: buffer too long");
- return;
- }
-
- if (str[0] == '!') {
- // Fatal error.
- DWORD gle = ::GetLastError();
- if (::IsDebuggerPresent())
- __debugbreak();
- wsprintfA(buf, "ODS:fatal %s (%p) gle=0x%x", str, val, gle);
- ::MessageBoxA(NULL, buf, "!!!", MB_OK);
- ::ExitProcess(gle);
- } else {
- // Just information.
- wsprintfA(buf, "ODS:%s (%p)\n", str, val);
- ::OutputDebugStringA(buf);
- }
-}
+EXTERN_C IMAGE_DOS_HEADER __ImageBase;
LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
WPARAM wparam, LPARAM lparam) {
@@ -50,7 +20,6 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
break;
case WM_DESTROY:
PostQuitMessage(0);
- ODS("Metro WM_DESTROY received");
break;
default:
return DefWindowProc(hwnd, message, wparam, lparam);
@@ -62,78 +31,522 @@ HWND CreateMetroTopLevelWindow() {
HINSTANCE hInst = reinterpret_cast<HINSTANCE>(&__ImageBase);
WNDCLASSEXW wcex;
wcex.cbSize = sizeof(wcex);
- wcex.style = CS_HREDRAW | CS_VREDRAW;
- wcex.lpfnWndProc = WndProc;
- wcex.cbClsExtra = 0;
- wcex.cbWndExtra = 0;
- wcex.hInstance = hInst;
- wcex.hIcon = 0;
- wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
- wcex.hbrBackground = (HBRUSH)(COLOR_INACTIVECAPTION+1);
- wcex.lpszMenuName = 0;
- wcex.lpszClassName = L"Windows.UI.Core.CoreWindow";
- wcex.hIconSm = 0;
+ wcex.style = CS_HREDRAW | CS_VREDRAW;
+ wcex.lpfnWndProc = WndProc;
+ wcex.cbClsExtra = 0;
+ wcex.cbWndExtra = 0;
+ wcex.hInstance = hInst;
+ wcex.hIcon = 0;
+ wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wcex.hbrBackground = (HBRUSH)(COLOR_INACTIVECAPTION+1);
+ wcex.lpszMenuName = 0;
+ wcex.lpszClassName = L"Windows.UI.Core.CoreWindow";
+ wcex.hIconSm = 0;
HWND hwnd = ::CreateWindowExW(0,
MAKEINTATOM(::RegisterClassExW(&wcex)),
- L"metro_metro",
+ L"metro_win7",
WS_POPUP,
0, 0, 0, 0,
NULL, NULL, hInst, NULL);
return hwnd;
}
-DWORD WINAPI HostThread(void*) {
- // The sleeps simulates the delay we have in the actual metro code
- // which takes in account the corewindow being created and some other
- // unknown machinations of metro.
- ODS("Chrome main thread", ::GetCurrentThreadId());
- ::Sleep(30);
- return globals.host_main(globals.host_context);
-}
+typedef winfoundtn::ITypedEventHandler<
+ winapp::Core::CoreApplicationView*,
+ winapp::Activation::IActivatedEventArgs*> ActivatedHandler;
-extern "C" __declspec(dllexport)
-int InitMetro(LPTHREAD_START_ROUTINE thread_proc, void* context) {
- ODS("InitMetro [Win7 emulation]");
- HWND window = CreateMetroTopLevelWindow();
- if (!window)
- return 1;
- // This magic incatation tells windows that the window is going fullscreen
- // so the taskbar gets out of the wait automatically.
- ::SetWindowPos(window,
- HWND_TOP,
- 0,0,
- GetSystemMetrics(SM_CXSCREEN),
- GetSystemMetrics(SM_CYSCREEN),
- SWP_SHOWWINDOW);
-
- // Ready to start our caller.
- globals.core_window = window;
- globals.host_main = thread_proc;
- globals.host_context = context;
- HANDLE thread = ::CreateThread(NULL, 0, &HostThread, NULL, 0, NULL);
-
- // Main message loop.
- MSG msg = {0};
- while (GetMessage(&msg, NULL, 0, 0)) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
-
- return (int) msg.wParam;
-}
+typedef winfoundtn::ITypedEventHandler<
+ winui::Core::CoreWindow*,
+ winui::Core::WindowActivatedEventArgs*> WindowActivatedHandler;
-extern "C" _declspec(dllexport) HWND GetRootWindow() {
- ODS("GetRootWindow", ULONG_PTR(globals.core_window));
- return globals.core_window;
-}
+typedef winfoundtn::ITypedEventHandler<
+ winui::Core::CoreWindow*,
+ winui::Core::AutomationProviderRequestedEventArgs*>
+ AutomationProviderHandler;
+
+typedef winfoundtn::ITypedEventHandler<
+ winui::Core::CoreWindow*,
+ winui::Core::CharacterReceivedEventArgs*> CharEventHandler;
+
+typedef winfoundtn::ITypedEventHandler<
+ winui::Core::CoreWindow*,
+ winui::Core::CoreWindowEventArgs*> CoreWindowEventHandler;
+
+typedef winfoundtn::ITypedEventHandler<
+ winui::Core::CoreWindow*,
+ winui::Core::InputEnabledEventArgs*> InputEnabledEventHandler;
+
+typedef winfoundtn::ITypedEventHandler<
+ winui::Core::CoreWindow*,
+ winui::Core::KeyEventArgs*> KeyEventHandler;
+
+typedef winfoundtn::ITypedEventHandler<
+ winui::Core::CoreWindow*,
+ winui::Core::PointerEventArgs*> PointerEventHandler;
+
+typedef winfoundtn::ITypedEventHandler<
+ winui::Core::CoreWindow*,
+ winui::Core::WindowSizeChangedEventArgs*> SizeChangedHandler;
+
+typedef winfoundtn::ITypedEventHandler<
+ winui::Core::CoreWindow*,
+ winui::Core::TouchHitTestingEventArgs*> TouchHitTestHandler;
+
+typedef winfoundtn::ITypedEventHandler<
+ winui::Core::CoreWindow*,
+ winui::Core::VisibilityChangedEventArgs*> VisibilityChangedHandler;
+
+// The following classes are the emulation of the WinRT system as exposed
+// to metro applications. There is one application (ICoreApplication) which
+// contains a series of Views (ICoreApplicationView) each one of them
+// containing a CoreWindow which represents a surface that can drawn to
+// and that receives events.
+//
+// Here is the general dependency hierachy in terms of interfaces:
+//
+// IFrameworkViewSource --> IFrameworkView
+// ^ |
+// | | metro app
+// ---------------------------------------------------------------------
+// | | winRT system
+// | v
+// ICoreApplication ICoreApplicationView
+// |
+// v
+// ICoreWindow ----> ICoreWindowInterop
+// |
+// |
+// V
+// real HWND
+//
+
+class CoreWindowEmulation
+ : public mswr::RuntimeClass<
+ mswr::RuntimeClassFlags<mswr::WinRtClassicComMix>,
+ winui::Core::ICoreWindow, ICoreWindowInterop> {
+ public:
+ // ICoreWindow implementation:
+ virtual HRESULT STDMETHODCALLTYPE get_AutomationHostProvider(
+ IInspectable **value) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE get_Bounds(
+ winfoundtn::Rect* value) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE get_CustomProperties(
+ winfoundtn::Collections::IPropertySet **value) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE get_Dispatcher(
+ winui::Core::ICoreDispatcher **value) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE get_FlowDirection(
+ winui::Core::CoreWindowFlowDirection* value) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE put_FlowDirection(
+ winui::Core::CoreWindowFlowDirection value) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE get_IsInputEnabled(
+ boolean* value) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE put_IsInputEnabled(
+ boolean value) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE get_PointerCursor(
+ winui::Core::ICoreCursor **value) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE put_PointerCursor(
+ winui::Core::ICoreCursor* value) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE get_PointerPosition(
+ winfoundtn::Point* value) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE get_Visible(
+ boolean* value) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE Activate(void) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE Close(void) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE GetAsyncKeyState(
+ ABI::Windows::System::VirtualKey virtualKey,
+ winui::Core::CoreVirtualKeyStates* KeyState) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE GetKeyState(
+ ABI::Windows::System::VirtualKey virtualKey,
+ winui::Core::CoreVirtualKeyStates* KeyState) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE ReleasePointerCapture(void) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE SetPointerCapture(void) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE add_Activated(
+ WindowActivatedHandler* handler,
+ EventRegistrationToken* pCookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE remove_Activated(
+ EventRegistrationToken cookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE add_AutomationProviderRequested(
+ AutomationProviderHandler* handler,
+ EventRegistrationToken* cookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE remove_AutomationProviderRequested(
+ EventRegistrationToken cookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE add_CharacterReceived(
+ CharEventHandler* handler,
+ EventRegistrationToken* pCookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE remove_CharacterReceived(
+ EventRegistrationToken cookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE add_Closed(
+ CoreWindowEventHandler* handler,
+ EventRegistrationToken* pCookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE remove_Closed(
+ EventRegistrationToken cookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE add_InputEnabled(
+ InputEnabledEventHandler* handler,
+ EventRegistrationToken* pCookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE remove_InputEnabled(
+ EventRegistrationToken cookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE add_KeyDown(
+ KeyEventHandler* handler,
+ EventRegistrationToken* pCookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE remove_KeyDown(
+ EventRegistrationToken cookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE add_KeyUp(
+ KeyEventHandler* handler,
+ EventRegistrationToken* pCookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE remove_KeyUp(
+ EventRegistrationToken cookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE add_PointerCaptureLost(
+ PointerEventHandler* handler,
+ EventRegistrationToken* cookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE remove_PointerCaptureLost(
+ EventRegistrationToken cookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE add_PointerEntered(
+ PointerEventHandler* handler,
+ EventRegistrationToken* cookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE remove_PointerEntered(
+ EventRegistrationToken cookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE add_PointerExited(
+ PointerEventHandler* handler,
+ EventRegistrationToken* cookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE remove_PointerExited(
+ EventRegistrationToken cookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE add_PointerMoved(
+ PointerEventHandler* handler,
+ EventRegistrationToken* cookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE remove_PointerMoved(
+ EventRegistrationToken cookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE add_PointerPressed(
+ PointerEventHandler* handler,
+ EventRegistrationToken* cookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE remove_PointerPressed(
+ EventRegistrationToken cookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE add_PointerReleased(
+ PointerEventHandler* handler,
+ EventRegistrationToken* cookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE remove_PointerReleased(
+ EventRegistrationToken cookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE add_TouchHitTesting(
+ TouchHitTestHandler* handler,
+ EventRegistrationToken* pCookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE remove_TouchHitTesting(
+ EventRegistrationToken cookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE add_PointerWheelChanged(
+ PointerEventHandler* handler,
+ EventRegistrationToken* cookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE remove_PointerWheelChanged(
+ EventRegistrationToken cookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE add_SizeChanged(
+ SizeChangedHandler* handler,
+ EventRegistrationToken* pCookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE remove_SizeChanged(
+ EventRegistrationToken cookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE add_VisibilityChanged(
+ VisibilityChangedHandler* handler,
+ EventRegistrationToken* pCookie) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE remove_VisibilityChanged(
+ EventRegistrationToken cookie) {
+ return S_OK;
+ }
+
+ // ICoreWindowInterop implementation:
+ virtual HRESULT STDMETHODCALLTYPE get_WindowHandle(
+ HWND *hwnd) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE put_MessageHandled(
+ boolean value) {
+ return S_OK;
+ }
+
+};
+
+class CoreApplicationViewEmulation
+ : public mswr::RuntimeClass<winapp::Core::ICoreApplicationView> {
+ public:
+ CoreApplicationViewEmulation() {
+ core_window_ = mswr::Make<CoreWindowEmulation>();
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE get_CoreWindow(
+ winui::Core::ICoreWindow **value) {
+ if (!core_window_)
+ return E_FAIL;
+ *value = core_window_.Get();
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE add_Activated(
+ ActivatedHandler* handler,
+ EventRegistrationToken* token) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE remove_Activated(
+ EventRegistrationToken token) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE get_IsMain(
+ boolean* value) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE get_IsHosted(
+ boolean* value) {
+ return S_OK;
+ }
+
+ private:
+ mswr::ComPtr<winui::Core::ICoreWindow> core_window_;
+};
+
+class CoreApplicationWin7Emulation
+ : public mswr::RuntimeClass<winapp::Core::ICoreApplication,
+ winapp::Core::ICoreApplicationExit> {
+ public:
+ // ICoreApplication implementation:
+
+ virtual HRESULT STDMETHODCALLTYPE get_Id(
+ HSTRING* value) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE add_Suspending(
+ winfoundtn::IEventHandler<winapp::SuspendingEventArgs*>* handler,
+ EventRegistrationToken* token) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE remove_Suspending(
+ EventRegistrationToken token) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE add_Resuming(
+ winfoundtn::IEventHandler<IInspectable*>* handler,
+ EventRegistrationToken* token) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE remove_Resuming(
+ EventRegistrationToken token) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE get_Properties(
+ winfoundtn::Collections::IPropertySet** value) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE GetCurrentView(
+ winapp::Core::ICoreApplicationView** value) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE Run(
+ winapp::Core::IFrameworkViewSource* viewSource) {
+ HRESULT hr = viewSource->CreateView(app_view_.GetAddressOf());
+ if (FAILED(hr))
+ return hr;
+ view_emulation_ = mswr::Make<CoreApplicationViewEmulation>();
+ hr = app_view_->Initialize(view_emulation_.Get());
+ if (FAILED(hr))
+ return hr;
+ mswr::ComPtr<winui::Core::ICoreWindow> core_window;
+ hr = view_emulation_->get_CoreWindow(core_window.GetAddressOf());
+ if (FAILED(hr))
+ return hr;
+ hr = app_view_->SetWindow(core_window.Get());
+ return hr;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE RunWithActivationFactories(
+ winfoundtn::IGetActivationFactory* activationFactoryCallback) {
+ return S_OK;
+ }
+
+ // ICoreApplicationExit implementation:
+
+ virtual HRESULT STDMETHODCALLTYPE Exit(void) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE add_Exiting(
+ winfoundtn::IEventHandler<IInspectable*>* handler,
+ EventRegistrationToken* token) {
+ return S_OK;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE remove_Exiting(
+ EventRegistrationToken token) {
+ return S_OK;
+ }
+
+ private:
+ mswr::ComPtr<winapp::Core::IFrameworkView> app_view_;
+ mswr::ComPtr<winapp::Core::ICoreApplicationView> view_emulation_;
+};
-extern "C" _declspec(dllexport) void SetFrameWindow(HWND window) {
- ODS("SetFrameWindow", ULONG_PTR(window));
- globals.host_window = window;
-}
-extern "C" __declspec(dllexport) const wchar_t* GetInitialUrl() {
- return L"";
+mswr::ComPtr<winapp::Core::ICoreApplication> InitWindows7() {
+ HRESULT hr = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
+ if (FAILED(hr))
+ CHECK(false);
+ return mswr::Make<CoreApplicationWin7Emulation>();
}