Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(623)

Side by Side Diff: ui/gfx/win/window_impl.cc

Issue 2093323002: Allow Chrome's Non-Client Area To Be Scaled on DPI Changes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wmdpi
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ui/gfx/win/window_impl.h" 5 #include "ui/gfx/win/window_impl.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/debug/alias.h" 10 #include "base/debug/alias.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
15 #include "base/win/win_util.h"
15 #include "base/win/wrapped_window_proc.h" 16 #include "base/win/wrapped_window_proc.h"
16 #include "ui/gfx/win/hwnd_util.h" 17 #include "ui/gfx/win/hwnd_util.h"
17 18
18 namespace gfx { 19 namespace gfx {
19 20
20 static const DWORD kWindowDefaultChildStyle = 21 static const DWORD kWindowDefaultChildStyle =
21 WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; 22 WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
22 static const DWORD kWindowDefaultStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN; 23 static const DWORD kWindowDefaultStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN;
23 static const DWORD kWindowDefaultExStyle = 0; 24 static const DWORD kWindowDefaultExStyle = 0;
24 25
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 height = bounds.height(); 206 height = bounds.height();
206 } 207 }
207 208
208 ATOM atom = GetWindowClassAtom(); 209 ATOM atom = GetWindowClassAtom();
209 bool destroyed = false; 210 bool destroyed = false;
210 destroyed_ = &destroyed; 211 destroyed_ = &destroyed;
211 HWND hwnd = CreateWindowEx(window_ex_style_, 212 HWND hwnd = CreateWindowEx(window_ex_style_,
212 reinterpret_cast<wchar_t*>(atom), NULL, 213 reinterpret_cast<wchar_t*>(atom), NULL,
213 window_style_, x, y, width, height, 214 window_style_, x, y, width, height,
214 parent, NULL, NULL, this); 215 parent, NULL, NULL, this);
216 if (hwnd && base::win::IsProcessPerMonitorDpiAware()) {
217 static auto enable_child_window_dpi_message_func = []() {
218 // Derived signature; not available in headers.
219 // This call gets Windows to scale the non-client area when WM_DPICHANGED
220 // is fired.
scottmg 2016/06/27 19:26:35 Any semi-documentation you can link here?
robliao 2016/06/27 19:58:07 Unfortunately not that I can find. This is pretty
221 using EnableChildWindowDpiMessagePtr = LRESULT (WINAPI*)(HWND, BOOL);
222 HMODULE user32 = GetModuleHandle(L"user32");
scottmg 2016/06/27 19:26:35 Other instances seem to include ".dll".
robliao 2016/06/27 19:58:07 Done.
223 if (user32) {
scottmg 2016/06/27 19:26:35 Don't think you need to check user32 here, just in
robliao 2016/06/27 19:58:07 Done. Yup, we seem to do it in other places indeed
224 return reinterpret_cast<EnableChildWindowDpiMessagePtr>(
225 GetProcAddress(user32, "EnableChildWindowDpiMessage"));
226 }
227 return reinterpret_cast<EnableChildWindowDpiMessagePtr>(nullptr);
228 }();
229 if (enable_child_window_dpi_message_func)
230 enable_child_window_dpi_message_func(hwnd, TRUE);
231 }
215 232
216 // First nccalcszie (during CreateWindow) for captioned windows is 233 // First nccalcszie (during CreateWindow) for captioned windows is
217 // deliberately ignored so force a second one here to get the right 234 // deliberately ignored so force a second one here to get the right
218 // non-client set up. 235 // non-client set up.
219 if (hwnd && (window_style_ & WS_CAPTION)) { 236 if (hwnd && (window_style_ & WS_CAPTION)) {
220 SetWindowPos(hwnd, NULL, 0, 0, 0, 0, 237 SetWindowPos(hwnd, NULL, 0, 0, 0, 0,
221 SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | 238 SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE |
222 SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW); 239 SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW);
223 } 240 }
224 241
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 } 320 }
304 321
305 ATOM WindowImpl::GetWindowClassAtom() { 322 ATOM WindowImpl::GetWindowClassAtom() {
306 HICON icon = GetDefaultWindowIcon(); 323 HICON icon = GetDefaultWindowIcon();
307 HICON small_icon = GetSmallWindowIcon(); 324 HICON small_icon = GetSmallWindowIcon();
308 ClassInfo class_info(initial_class_style(), icon, small_icon); 325 ClassInfo class_info(initial_class_style(), icon, small_icon);
309 return ClassRegistrar::GetInstance()->RetrieveClassAtom(class_info); 326 return ClassRegistrar::GetInstance()->RetrieveClassAtom(class_info);
310 } 327 }
311 328
312 } // namespace gfx 329 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698