From d678d9ee7521d93e7a269f02966332151122c42a Mon Sep 17 00:00:00 2001 From: Troy Date: Tue, 9 Oct 2018 10:08:15 -0700 Subject: [PATCH] fix: Check minSize constraints before resizing (#14931) * Inital setSize check * Only resize if above minimum size constraints * lint * Resize to min if size is changed * Remove unneeded if statement * chore: remove trailing whitespace * Add note about setSize method in docs --- atom/browser/api/atom_api_top_level_window.cc | 4 +++- docs/api/browser-window.md | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/atom/browser/api/atom_api_top_level_window.cc b/atom/browser/api/atom_api_top_level_window.cc index 02a0d8a240..9fc9565c4e 100644 --- a/atom/browser/api/atom_api_top_level_window.cc +++ b/atom/browser/api/atom_api_top_level_window.cc @@ -403,8 +403,10 @@ gfx::Rect TopLevelWindow::GetContentBounds() { void TopLevelWindow::SetSize(int width, int height, mate::Arguments* args) { bool animate = false; + gfx::Size size = window_->GetMinimumSize(); + size.SetToMax(gfx::Size(width, height)); args->GetNext(&animate); - window_->SetSize(gfx::Size(width, height), animate); + window_->SetSize(size, animate); } std::vector TopLevelWindow::GetSize() { diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 10d3a40aaf..3dbb79c538 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -920,7 +920,7 @@ Disable or enable the window. * `height` Integer * `animate` Boolean (optional) _macOS_ -Resizes the window to `width` and `height`. +Resizes the window to `width` and `height`. If `width` or `height` are below any set minimum size constraints the window will snap to its minimum size. #### `win.getSize()`