]> khamidou — GitHub mirrors - electron.git/commitdiff
views: Restore window state when showing window
authorCheng Zhao <zcbenz@gmail.com>
Thu, 26 Mar 2015 08:39:03 +0000 (16:39 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 26 Mar 2015 08:43:38 +0000 (16:43 +0800)
atom/browser/native_window_views.cc
atom/browser/native_window_views.h

index 8d34180c99177770fe3ec849f31463ed7f81bdd8..b0685eb2ff3b504e2e6e3f009909e3d67445fc4f 100644 (file)
@@ -307,7 +307,7 @@ bool NativeWindowViews::IsFocused() {
 }
 
 void NativeWindowViews::Show() {
-  window_->Show();
+  window_->native_widget_private()->ShowWithWindowState(GetRestoredState());
 }
 
 void NativeWindowViews::ShowInactive() {
@@ -927,6 +927,15 @@ gfx::Rect NativeWindowViews::ContentBoundsToWindowBounds(
   return window_bounds;
 }
 
+ui::WindowShowState NativeWindowViews::GetRestoredState() {
+  if (IsMaximized())
+    return ui::SHOW_STATE_MAXIMIZED;
+  if (IsFullscreen())
+    return ui::SHOW_STATE_FULLSCREEN;
+
+  return ui::SHOW_STATE_NORMAL;
+}
+
 // static
 NativeWindow* NativeWindow::Create(content::WebContents* web_contents,
                                    const mate::Dictionary& options) {
index 24cc9c9f436be61db6bf9d7ef689b10d902a23a1..4221a687755c15c40da003ed6b2934fb32792b9f 100644 (file)
@@ -141,6 +141,9 @@ class NativeWindowViews : public NativeWindow,
   // in client area we need to substract/add menu bar's height in convertions.
   gfx::Rect ContentBoundsToWindowBounds(const gfx::Rect& content_bounds);
 
+  // Returns the restore state for the window.
+  ui::WindowShowState GetRestoredState();
+
   scoped_ptr<views::Widget> window_;
   views::View* web_view_;  // Managed by inspectable_web_contents_.