зеркало из https://github.com/electron/electron.git
fix: return proper values for WM_GETMINMAXINFO (#20519)
* fix: set proper constraints for windows with defined maxWidth When BrowserWindow has set constraints for width (max or min) it won't behave correctly during first attempt of resizing it. When maxWidth is defined and maxWidth equals its width it will shrink rapidly when user tries to expand its width. On the other hand when minWidth is defined and minWidth equals its width it's possible to decrease its width with a few pixels. Notes: Fixed improper behaviour of window with width constraint set during resize. * fix: prevent crash when WM_GETMINMAXINFO is called on initing window
This commit is contained in:
Родитель
be955a9721
Коммит
510a916f82
|
@ -1204,11 +1204,13 @@ gfx::Rect NativeWindowViews::ContentBoundsToWindowBounds(
|
|||
|
||||
gfx::Rect window_bounds(bounds);
|
||||
#if defined(OS_WIN)
|
||||
HWND hwnd = GetAcceleratedWidget();
|
||||
gfx::Rect dpi_bounds = DIPToScreenRect(hwnd, bounds);
|
||||
window_bounds = ScreenToDIPRect(
|
||||
hwnd,
|
||||
widget()->non_client_view()->GetWindowBoundsForClientBounds(dpi_bounds));
|
||||
if (widget()->non_client_view()) {
|
||||
HWND hwnd = GetAcceleratedWidget();
|
||||
gfx::Rect dpi_bounds = DIPToScreenRect(hwnd, bounds);
|
||||
window_bounds = ScreenToDIPRect(
|
||||
hwnd, widget()->non_client_view()->GetWindowBoundsForClientBounds(
|
||||
dpi_bounds));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (root_view_->HasMenu() && root_view_->IsMenuBarVisible()) {
|
||||
|
|
|
@ -356,14 +356,18 @@ bool NativeWindowViews::PreHandleMSG(UINT message,
|
|||
display::Screen::GetScreen()->GetDisplayNearestPoint(
|
||||
last_normal_placement_bounds_.origin());
|
||||
|
||||
const gfx::Size widget_min_size = widget()->GetMinimumSize();
|
||||
const gfx::Size widget_max_size = widget()->GetMaximumSize();
|
||||
gfx::Size min_size = gfx::ScaleToCeiledSize(
|
||||
widget()->GetMinimumSize(), display.device_scale_factor());
|
||||
ContentBoundsToWindowBounds(gfx::Rect(widget_min_size)).size(),
|
||||
display.device_scale_factor());
|
||||
gfx::Size max_size = gfx::ScaleToCeiledSize(
|
||||
widget()->GetMaximumSize(), display.device_scale_factor());
|
||||
ContentBoundsToWindowBounds(gfx::Rect(widget_max_size)).size(),
|
||||
display.device_scale_factor());
|
||||
|
||||
info->ptMinTrackSize.x = min_size.width();
|
||||
info->ptMinTrackSize.y = min_size.height();
|
||||
if (max_size.width() || max_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())
|
||||
|
|
Загрузка…
Ссылка в новой задаче