Skip to content

Commit ebd80a0

Browse files
authored
fix: max window size defaults to 0 (electron#33025)
1 parent 306147d commit ebd80a0

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

shell/browser/native_window.cc

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,25 @@ void NativeWindow::InitFromOptions(const gin_helper::Dictionary& options) {
161161
// On Linux and Window we may already have maximum size defined.
162162
extensions::SizeConstraints size_constraints(
163163
use_content_size ? GetContentSizeConstraints() : GetSizeConstraints());
164+
164165
int min_width = size_constraints.GetMinimumSize().width();
165166
int min_height = size_constraints.GetMinimumSize().height();
166167
options.Get(options::kMinWidth, &min_width);
167168
options.Get(options::kMinHeight, &min_height);
168169
size_constraints.set_minimum_size(gfx::Size(min_width, min_height));
169-
int max_width = size_constraints.GetMaximumSize().width();
170-
int max_height = size_constraints.GetMaximumSize().height();
171-
options.Get(options::kMaxWidth, &max_width);
172-
options.Get(options::kMaxHeight, &max_height);
173-
size_constraints.set_maximum_size(gfx::Size(max_width, max_height));
170+
171+
gfx::Size max_size = size_constraints.GetMaximumSize();
172+
int max_width = max_size.width() > 0 ? max_size.width() : INT_MAX;
173+
int max_height = max_size.height() > 0 ? max_size.height() : INT_MAX;
174+
bool have_max_width = options.Get(options::kMaxWidth, &max_width);
175+
bool have_max_height = options.Get(options::kMaxHeight, &max_height);
176+
177+
// By default the window has a default maximum size that prevents it
178+
// from being resized larger than the screen, so we should only set this
179+
// if th user has passed in values.
180+
if (have_max_height || have_max_width || !max_size.IsEmpty())
181+
size_constraints.set_maximum_size(gfx::Size(max_width, max_height));
182+
174183
if (use_content_size) {
175184
SetContentSizeConstraints(size_constraints);
176185
} else {

0 commit comments

Comments
 (0)