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 "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 Loading... |
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. |
| 221 using EnableChildWindowDpiMessagePtr = LRESULT (WINAPI*)(HWND, BOOL); |
| 222 return reinterpret_cast<EnableChildWindowDpiMessagePtr>( |
| 223 GetProcAddress(GetModuleHandle(L"user32.dll"), |
| 224 "EnableChildWindowDpiMessage")); |
| 225 }(); |
| 226 if (enable_child_window_dpi_message_func) |
| 227 enable_child_window_dpi_message_func(hwnd, TRUE); |
| 228 } |
215 | 229 |
216 // First nccalcszie (during CreateWindow) for captioned windows is | 230 // First nccalcszie (during CreateWindow) for captioned windows is |
217 // deliberately ignored so force a second one here to get the right | 231 // deliberately ignored so force a second one here to get the right |
218 // non-client set up. | 232 // non-client set up. |
219 if (hwnd && (window_style_ & WS_CAPTION)) { | 233 if (hwnd && (window_style_ & WS_CAPTION)) { |
220 SetWindowPos(hwnd, NULL, 0, 0, 0, 0, | 234 SetWindowPos(hwnd, NULL, 0, 0, 0, 0, |
221 SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | | 235 SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | |
222 SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW); | 236 SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW); |
223 } | 237 } |
224 | 238 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 } | 317 } |
304 | 318 |
305 ATOM WindowImpl::GetWindowClassAtom() { | 319 ATOM WindowImpl::GetWindowClassAtom() { |
306 HICON icon = GetDefaultWindowIcon(); | 320 HICON icon = GetDefaultWindowIcon(); |
307 HICON small_icon = GetSmallWindowIcon(); | 321 HICON small_icon = GetSmallWindowIcon(); |
308 ClassInfo class_info(initial_class_style(), icon, small_icon); | 322 ClassInfo class_info(initial_class_style(), icon, small_icon); |
309 return ClassRegistrar::GetInstance()->RetrieveClassAtom(class_info); | 323 return ClassRegistrar::GetInstance()->RetrieveClassAtom(class_info); |
310 } | 324 } |
311 | 325 |
312 } // namespace gfx | 326 } // namespace gfx |
OLD | NEW |