]> khamidou — GitHub mirrors - electron.git/commitdiff
views: Fix content size constraints in window with menubar
authorCheng Zhao <zcbenz@gmail.com>
Mon, 5 Oct 2015 16:15:10 +0000 (00:15 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 5 Oct 2015 16:15:47 +0000 (00:15 +0800)
atom/browser/native_window_views.cc

index 308e8ee3dcc0fec050fc1565f1eb29b87d2cee52..0e04414b6a47bdadf6d6b38a364b197e745678f8 100644 (file)
@@ -519,8 +519,24 @@ void NativeWindowViews::SetMenu(ui::MenuModel* menu_model) {
 
     if (!menu_bar_autohide_) {
       SetMenuBarVisibility(true);
-      if (use_content_size_)
+      if (use_content_size_) {
+        // Enlarge the size constraints for the menu.
+        extensions::SizeConstraints constraints = GetContentSizeConstraints();
+        if (constraints.HasMinimumSize()) {
+          gfx::Size min_size = constraints.GetMinimumSize();
+          min_size.set_height(min_size.height() + kMenuBarHeight);
+          constraints.set_minimum_size(min_size);
+        }
+        if (constraints.HasMaximumSize()) {
+          gfx::Size max_size = constraints.GetMaximumSize();
+          max_size.set_height(max_size.height() + kMenuBarHeight);
+          constraints.set_maximum_size(max_size);
+        }
+        SetContentSizeConstraints(constraints);
+
+        // Resize the window to make sure content size is not changed.
         SetContentSize(content_size);
+      }
     }
   }