Commit 3825541e authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Fix a crash dragging to another monitor with --force-device-scale-factor.

The new monitor's real DPI would override the forced scale factor, causing
DCHECK failures.  Instead, use the forced scale factor if it exists.

Bug: none
Test: Start a debug build of chrome on a two-monitor system with --force-device-scale-factor=1.5 (or some other value that doesn't match your monitors), drag the window from one monitor to the other.  This shouldn't cause a DCHECK failure.
Change-Id: I5ef336add05840f7ec2d7277b54855ef05e17d28
Reviewed-on: https://chromium-review.googlesource.com/1137481Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575513}
parent 126b44ea
...@@ -1599,18 +1599,26 @@ LRESULT HWNDMessageHandler::OnDpiChanged(UINT msg, ...@@ -1599,18 +1599,26 @@ LRESULT HWNDMessageHandler::OnDpiChanged(UINT msg,
if (LOWORD(w_param) != HIWORD(w_param)) if (LOWORD(w_param) != HIWORD(w_param))
NOTIMPLEMENTED() << "Received non-square scaling factors"; NOTIMPLEMENTED() << "Received non-square scaling factors";
int dpi;
float scaling_factor;
if (display::Display::HasForceDeviceScaleFactor()) {
scaling_factor = display::Display::GetForcedDeviceScaleFactor();
dpi = display::win::GetDPIFromScalingFactor(scaling_factor);
} else {
dpi = LOWORD(w_param);
scaling_factor = display::win::GetScalingFactorFromDPI(dpi_);
}
// The first WM_DPICHANGED originates from EnableChildWindowDpiMessage during // The first WM_DPICHANGED originates from EnableChildWindowDpiMessage during
// initialization. We don't want to propagate this as the client is already // initialization. We don't want to propagate this as the client is already
// set at the current scale factor and may cause the window to display too // set at the current scale factor and may cause the window to display too
// soon. See http://crbug.com/625076. // soon. See http://crbug.com/625076.
int dpi = LOWORD(w_param);
if (dpi_ == dpi) if (dpi_ == dpi)
return 0; return 0;
dpi_ = dpi; dpi_ = dpi;
SetBoundsInternal(gfx::Rect(*reinterpret_cast<RECT*>(l_param)), false); SetBoundsInternal(gfx::Rect(*reinterpret_cast<RECT*>(l_param)), false);
delegate_->HandleWindowScaleFactorChanged( delegate_->HandleWindowScaleFactorChanged(scaling_factor);
display::win::GetScalingFactorFromDPI(dpi_));
return 0; return 0;
} }
......
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