From 83024ea5098261fa6eee332dc1451aa7bbaccea4 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 26 Mar 2015 16:39:03 +0800 Subject: [PATCH] views: Restore window state when showing window --- atom/browser/native_window_views.cc | 11 ++++++++++- atom/browser/native_window_views.h | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 8d34180c99..b0685eb2ff 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 24cc9c9f43..4221a68775 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_.