From: Cheng Zhao Date: Thu, 26 Mar 2015 08:39:03 +0000 (+0800) Subject: views: Restore window state when showing window X-Git-Tag: v0.22.3~23^2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=83024ea5098261fa6eee332dc1451aa7bbaccea4;p=electron.git views: Restore window state when showing window --- diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 8d34180c..b0685eb2 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -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) { diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index 24cc9c9f..4221a687 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -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 window_; views::View* web_view_; // Managed by inspectable_web_contents_.