From 4dede048e98f9184769bf31c1bcd67c7331ea9cf Mon Sep 17 00:00:00 2001 From: "cpu@chromium.org" Date: Fri, 13 Jun 2014 03:57:25 +0000 Subject: [PATCH] Win7 Ash fullscreen mode Currently we have a fixed 1600x900 size, but the end goal is to be similar to win8 metro mode. This patch makes the window fullscreen respecting the taskbar area. If shift is held, starts at the old size so you can run a debugger next to it. BUG=none TEST=none Review URL: https://codereview.chromium.org/303673006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276913 0039d316-1c4b-4281-b951-d872f2087c98 --- win8/metro_driver/metro_driver_win7.cc | 37 ++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/win8/metro_driver/metro_driver_win7.cc b/win8/metro_driver/metro_driver_win7.cc index e357fe6a0732..3a4905798862 100644 --- a/win8/metro_driver/metro_driver_win7.cc +++ b/win8/metro_driver/metro_driver_win7.cc @@ -4,14 +4,22 @@ #include "stdafx.h" #include +#include #include "base/logging.h" #include "ui/gfx/geometry/safe_integer_conversions.h" #include "ui/gfx/win/msg_util.h" +#pragma comment(lib, "shell32.lib") + EXTERN_C IMAGE_DOS_HEADER __ImageBase; +// Even though we only create a single window, we need to keep this +// count because of the hidden window used by the UI message loop of +// the metro viewer. int g_window_count = 0; +const wchar_t kAshWin7AppId[] = L"Google.Chrome.AshWin7.1"; + extern float GetModernUIScale(); LRESULT CALLBACK WndProc(HWND hwnd, UINT message, @@ -43,7 +51,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, return 0; } -HWND CreateMetroTopLevelWindow() { +HWND CreateMetroTopLevelWindow(const RECT& work_area) { HINSTANCE hInst = reinterpret_cast(&__ImageBase); WNDCLASSEXW wcex; wcex.cbSize = sizeof(wcex); @@ -52,18 +60,21 @@ HWND CreateMetroTopLevelWindow() { wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInst; - wcex.hIcon = 0; + wcex.hIcon = LoadIcon(::GetModuleHandle(NULL), L"IDR_MAINFRAME"); 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.hIconSm = LoadIcon(::GetModuleHandle(NULL), L"IDR_MAINFRAME"); + + HWND hwnd = ::CreateWindowExW(0, MAKEINTATOM(::RegisterClassExW(&wcex)), L"metro_win7", - WS_POPUP | WS_VISIBLE, - 0, 0, 1600, 900, + WS_POPUP | WS_VISIBLE | WS_MINIMIZEBOX, + work_area.top, work_area.left, + work_area.right, work_area.bottom, NULL, NULL, hInst, NULL); return hwnd; } @@ -566,7 +577,21 @@ class CoreWindowEmulation key_up_handler_(NULL), character_received_handler_(NULL) { dispatcher_ = mswr::Make(this); - core_hwnd_ = CreateMetroTopLevelWindow(); + + // Unless we select our own AppUserModelID the shell might confuse us + // with the app launcher one and we get the wrong taskbar button and icon. + ::SetCurrentProcessExplicitAppUserModelID(kAshWin7AppId); + + RECT work_area = {0}; + ::SystemParametersInfo(SPI_GETWORKAREA, 0, &work_area, 0); + if (::IsDebuggerPresent()) { + work_area.top = 0; + work_area.left = 0; + work_area.right = 1600; + work_area.bottom = 900; + } + + core_hwnd_ = CreateMetroTopLevelWindow(work_area); } ~CoreWindowEmulation() { -- 2.11.4.GIT