From: Cheng Zhao Date: Mon, 5 Oct 2015 12:36:28 +0000 (+0800) Subject: Make min/max size respect use-content-size X-Git-Tag: v0.33.7~26^2~4^2~13 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=e675407552c808a43dea74ad8796cd0fa9d8c05e;p=electron.git Make min/max size respect use-content-size --- diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index cad6942d..f8023222 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -119,15 +119,23 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) { } else if (options.Get(switches::kCenter, ¢er) && center) { Center(); } + extensions::SizeConstraints size_constraints; int min_height = 0, min_width = 0; if (options.Get(switches::kMinHeight, &min_height) | options.Get(switches::kMinWidth, &min_width)) { - SetMinimumSize(gfx::Size(min_width, min_height)); + size_constraints.set_minimum_size(gfx::Size(min_width, min_height)); } int max_height = INT_MAX, max_width = INT_MAX; if (options.Get(switches::kMaxHeight, &max_height) | options.Get(switches::kMaxWidth, &max_width)) { - SetMaximumSize(gfx::Size(max_width, max_height)); + size_constraints.set_maximum_size(gfx::Size(max_width, max_height)); + } + bool use_content_size = false; + options.Get(switches::kUseContentSize, &use_content_size); + if (use_content_size) { + SetContentSizeConstraints(size_constraints); + } else { + SetSizeConstraints(size_constraints); } bool resizable; if (options.Get(switches::kResizable, &resizable)) {