Chromium Code Reviews| 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..73ae35021d3b1fd6f097b6539b6fba0587c684c2 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 0; |
|
sky
2016/12/14 02:42:41
Should this return TRUE (old code did).
robliao
2016/12/14 18:50:19
It should return FALSE, to doubly reenforce that w
|
| +} |
| + |
| LRESULT HWNDMessageHandler::OnNCHitTest(const gfx::Point& point) { |
| if (!delegate_->HasNonClientView()) { |
| SetMsgHandled(FALSE); |