Commit 4dede048 authored by cpu@chromium.org's avatar cpu@chromium.org

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
parent 607f020b
...@@ -4,14 +4,22 @@ ...@@ -4,14 +4,22 @@
#include "stdafx.h" #include "stdafx.h"
#include <corewindow.h> #include <corewindow.h>
#include <shobjidl.h>
#include "base/logging.h" #include "base/logging.h"
#include "ui/gfx/geometry/safe_integer_conversions.h" #include "ui/gfx/geometry/safe_integer_conversions.h"
#include "ui/gfx/win/msg_util.h" #include "ui/gfx/win/msg_util.h"
#pragma comment(lib, "shell32.lib")
EXTERN_C IMAGE_DOS_HEADER __ImageBase; 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; int g_window_count = 0;
const wchar_t kAshWin7AppId[] = L"Google.Chrome.AshWin7.1";
extern float GetModernUIScale(); extern float GetModernUIScale();
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
...@@ -43,7 +51,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, ...@@ -43,7 +51,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
return 0; return 0;
} }
HWND CreateMetroTopLevelWindow() { HWND CreateMetroTopLevelWindow(const RECT& work_area) {
HINSTANCE hInst = reinterpret_cast<HINSTANCE>(&__ImageBase); HINSTANCE hInst = reinterpret_cast<HINSTANCE>(&__ImageBase);
WNDCLASSEXW wcex; WNDCLASSEXW wcex;
wcex.cbSize = sizeof(wcex); wcex.cbSize = sizeof(wcex);
...@@ -52,18 +60,21 @@ HWND CreateMetroTopLevelWindow() { ...@@ -52,18 +60,21 @@ HWND CreateMetroTopLevelWindow() {
wcex.cbClsExtra = 0; wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0; wcex.cbWndExtra = 0;
wcex.hInstance = hInst; wcex.hInstance = hInst;
wcex.hIcon = 0; wcex.hIcon = LoadIcon(::GetModuleHandle(NULL), L"IDR_MAINFRAME");
wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_INACTIVECAPTION+1); wcex.hbrBackground = (HBRUSH)(COLOR_INACTIVECAPTION+1);
wcex.lpszMenuName = 0; wcex.lpszMenuName = 0;
wcex.lpszClassName = L"Windows.UI.Core.CoreWindow"; wcex.lpszClassName = L"Windows.UI.Core.CoreWindow";
wcex.hIconSm = 0; wcex.hIconSm = LoadIcon(::GetModuleHandle(NULL), L"IDR_MAINFRAME");
HWND hwnd = ::CreateWindowExW(0, HWND hwnd = ::CreateWindowExW(0,
MAKEINTATOM(::RegisterClassExW(&wcex)), MAKEINTATOM(::RegisterClassExW(&wcex)),
L"metro_win7", L"metro_win7",
WS_POPUP | WS_VISIBLE, WS_POPUP | WS_VISIBLE | WS_MINIMIZEBOX,
0, 0, 1600, 900, work_area.top, work_area.left,
work_area.right, work_area.bottom,
NULL, NULL, hInst, NULL); NULL, NULL, hInst, NULL);
return hwnd; return hwnd;
} }
...@@ -566,7 +577,21 @@ class CoreWindowEmulation ...@@ -566,7 +577,21 @@ class CoreWindowEmulation
key_up_handler_(NULL), key_up_handler_(NULL),
character_received_handler_(NULL) { character_received_handler_(NULL) {
dispatcher_ = mswr::Make<CoreDispatcherEmulation>(this); dispatcher_ = mswr::Make<CoreDispatcherEmulation>(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() { ~CoreWindowEmulation() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment