From 21cd6fbe54dff3e98a75ede2570827cce0052bfe Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Mon, 21 Feb 2022 11:39:40 +0100 Subject: [PATCH 1/2] fix: max window size defaults to 0 --- shell/browser/native_window.cc | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/shell/browser/native_window.cc b/shell/browser/native_window.cc index 74ef7d1bf9e5e..90c2b8630abcb 100644 --- a/shell/browser/native_window.cc +++ b/shell/browser/native_window.cc @@ -161,16 +161,25 @@ void NativeWindow::InitFromOptions(const gin_helper::Dictionary& options) { // On Linux and Window we may already have maximum size defined. extensions::SizeConstraints size_constraints( use_content_size ? GetContentSizeConstraints() : GetSizeConstraints()); + int min_width = size_constraints.GetMinimumSize().width(); int min_height = size_constraints.GetMinimumSize().height(); options.Get(options::kMinWidth, &min_width); options.Get(options::kMinHeight, &min_height); size_constraints.set_minimum_size(gfx::Size(min_width, min_height)); - int max_width = size_constraints.GetMaximumSize().width(); - int max_height = size_constraints.GetMaximumSize().height(); - options.Get(options::kMaxWidth, &max_width); - options.Get(options::kMaxHeight, &max_height); - size_constraints.set_maximum_size(gfx::Size(max_width, max_height)); + + gfx::Size max_size = size_constraints.GetMaximumSize(); + int max_width = max_size.width() > 0 ? max_size.width() : INT_MAX; + int max_height = max_size.height() > 0 ? max_size.height() : INT_MAX; + bool have_max_width = options.Get(options::kMaxWidth, &max_width); + bool have_max_height = options.Get(options::kMaxHeight, &max_height); + + // By default the window has a default maximum size that prevents it + // from being resized larger than the screen, so we should only set this + // if th user has passed in values. + if (have_max_height || have_max_width) + size_constraints.set_maximum_size(gfx::Size(max_width, max_height)); + if (use_content_size) { SetContentSizeConstraints(size_constraints); } else { From 99bc58b99029cd4651a4a0545fa0c448d1e9c3c0 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Wed, 23 Feb 2022 11:52:30 +0100 Subject: [PATCH 2/2] fix: also check max_size empty --- shell/browser/native_window.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/browser/native_window.cc b/shell/browser/native_window.cc index 90c2b8630abcb..6e42c30304943 100644 --- a/shell/browser/native_window.cc +++ b/shell/browser/native_window.cc @@ -177,7 +177,7 @@ void NativeWindow::InitFromOptions(const gin_helper::Dictionary& options) { // By default the window has a default maximum size that prevents it // from being resized larger than the screen, so we should only set this // if th user has passed in values. - if (have_max_height || have_max_width) + if (have_max_height || have_max_width || !max_size.IsEmpty()) size_constraints.set_maximum_size(gfx::Size(max_width, max_height)); if (use_content_size) {