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

Unified Diff: ui/views/win/hwnd_message_handler.cc

Issue 2574933002: Call EnableNonClientDpiScaling (Closed)
Patch Set: Fix Bad Test Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/win/hwnd_message_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/win/hwnd_message_handler.cc
diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc
index c9eb44424c31ada6f659d4a4bcf1d6207b343f1d..54116a2f52c544592df61db5a37b8786b0882306 100644
--- a/ui/views/win/hwnd_message_handler.cc
+++ b/ui/views/win/hwnd_message_handler.cc
@@ -329,6 +329,7 @@ HWNDMessageHandler::HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate)
current_cursor_(NULL),
previous_cursor_(NULL),
dpi_(0),
+ called_enable_non_client_dpi_scaling_(false),
active_mouse_tracking_flags_(0),
is_right_mouse_pressed_on_caption_(false),
lock_updates_count_(0),
@@ -362,7 +363,9 @@ void HWNDMessageHandler::Init(HWND parent, const gfx::Rect& bounds) {
// Create the window.
WindowImpl::Init(parent, bounds);
- if (delegate_->HasFrame() && base::win::IsProcessPerMonitorDpiAware()) {
+ if (!called_enable_non_client_dpi_scaling_ &&
+ delegate_->HasFrame() &&
+ base::win::IsProcessPerMonitorDpiAware()) {
static auto enable_child_window_dpi_message_func = []() {
// Derived signature; not available in headers.
// This call gets Windows to scale the non-client area when WM_DPICHANGED
@@ -1795,6 +1798,24 @@ LRESULT HWNDMessageHandler::OnNCCalcSize(BOOL mode, LPARAM l_param) {
return mode ? WVR_REDRAW : 0;
}
+LRESULT HWNDMessageHandler::OnNCCreate(LPCREATESTRUCT lpCreateStruct) {
+ SetMsgHandled(FALSE);
+ if (delegate_->HasFrame() && base::win::IsProcessPerMonitorDpiAware()) {
+ static auto enable_non_client_dpi_scaling_func = []() {
+ // Signature only available in the 10.0.14393.0 API. As of this writing,
+ // Chrome built against 10.0.10586.0.
+ using EnableNonClientDpiScalingPtr = LRESULT (WINAPI*)(HWND);
+ return reinterpret_cast<EnableNonClientDpiScalingPtr>(
+ GetProcAddress(GetModuleHandle(L"user32.dll"),
+ "EnableNonClientDpiScaling"));
+ }();
+ called_enable_non_client_dpi_scaling_ =
+ !!(enable_non_client_dpi_scaling_func &&
+ enable_non_client_dpi_scaling_func(hwnd()));
+ }
+ return FALSE;
+}
+
LRESULT HWNDMessageHandler::OnNCHitTest(const gfx::Point& point) {
if (!delegate_->HasNonClientView()) {
SetMsgHandled(FALSE);
« no previous file with comments | « ui/views/win/hwnd_message_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698