fix: incorrect size of windows on differently scaled monitors (#21100)
* Revert "fix: handle WM_GETMINMAXINFO instead of letting chromium do it (#19928)"
This reverts commit 27ce6a9cd3
.
* fix: don't reset the width and height when correcting window placement
This commit is contained in:
parent
46c12308cd
commit
fbc3bb872b
1 changed files with 13 additions and 29 deletions
|
@ -345,39 +345,23 @@ bool NativeWindowViews::PreHandleMSG(UINT message,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case WM_GETMINMAXINFO: {
|
case WM_GETMINMAXINFO: {
|
||||||
// We need to handle GETMINMAXINFO ourselves because chromium tries to
|
WINDOWPLACEMENT wp;
|
||||||
// get the scale factor of the window during it's version of this handler
|
wp.length = sizeof(WINDOWPLACEMENT);
|
||||||
// based on the window position, which is invalid at this point. The
|
|
||||||
// previous method of calling SetWindowPlacement fixed the window
|
|
||||||
// position for the scale factor calculation but broke other things.
|
|
||||||
MINMAXINFO* info = reinterpret_cast<MINMAXINFO*>(l_param);
|
|
||||||
|
|
||||||
display::Display display =
|
// We do this to work around a Windows bug, where the minimized Window
|
||||||
display::Screen::GetScreen()->GetDisplayNearestPoint(
|
// would report that the closest display to it is not the one that it was
|
||||||
last_normal_placement_bounds_.origin());
|
// previously on (but the leftmost one instead). We restore the position
|
||||||
|
// of the window during the restore operation, this way chromium can
|
||||||
|
// use the proper display to calculate the scale factor to use.
|
||||||
|
if (!last_normal_placement_bounds_.IsEmpty() &&
|
||||||
|
GetWindowPlacement(GetAcceleratedWidget(), &wp)) {
|
||||||
|
wp.rcNormalPosition = last_normal_placement_bounds_.ToRECT();
|
||||||
|
SetWindowPlacement(GetAcceleratedWidget(), &wp);
|
||||||
|
|
||||||
const gfx::Size widget_min_size = widget()->GetMinimumSize();
|
last_normal_placement_bounds_ = gfx::Rect();
|
||||||
const gfx::Size widget_max_size = widget()->GetMaximumSize();
|
|
||||||
gfx::Size min_size = gfx::ScaleToCeiledSize(
|
|
||||||
ContentBoundsToWindowBounds(gfx::Rect(widget_min_size)).size(),
|
|
||||||
display.device_scale_factor());
|
|
||||||
gfx::Size max_size = gfx::ScaleToCeiledSize(
|
|
||||||
ContentBoundsToWindowBounds(gfx::Rect(widget_max_size)).size(),
|
|
||||||
display.device_scale_factor());
|
|
||||||
|
|
||||||
info->ptMinTrackSize.x = min_size.width();
|
|
||||||
info->ptMinTrackSize.y = min_size.height();
|
|
||||||
if (widget_max_size.width() || widget_max_size.height()) {
|
|
||||||
if (!max_size.width())
|
|
||||||
max_size.set_width(GetSystemMetrics(SM_CXMAXTRACK));
|
|
||||||
if (!max_size.height())
|
|
||||||
max_size.set_height(GetSystemMetrics(SM_CYMAXTRACK));
|
|
||||||
info->ptMaxTrackSize.x = max_size.width();
|
|
||||||
info->ptMaxTrackSize.y = max_size.height();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*result = 1;
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
case WM_NCCALCSIZE: {
|
case WM_NCCALCSIZE: {
|
||||||
if (!has_frame() && w_param == TRUE) {
|
if (!has_frame() && w_param == TRUE) {
|
||||||
|
|
Loading…
Reference in a new issue