diff options
author | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-31 23:27:33 +0000 |
---|---|---|
committer | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-31 23:27:33 +0000 |
commit | 0fbe67bd15d7e81751ac0532a388315a714ccb6c (patch) | |
tree | b638b9f2c220e2dd2057fd7b1d764b4f7ba6a7d8 /views/widget | |
parent | bba630ced52644aaeab2a3e3d5c8348acdcca543 (diff) | |
download | chromium_src-0fbe67bd15d7e81751ac0532a388315a714ccb6c.zip chromium_src-0fbe67bd15d7e81751ac0532a388315a714ccb6c.tar.gz chromium_src-0fbe67bd15d7e81751ac0532a388315a714ccb6c.tar.bz2 |
Restoring a session should restore window minimization state on Windows
These changes enable save and restore of minimized window state on Windows. (Mac and Linux came prior). The window state is now saved whenever size-changed notifications fire (in addition to the original activation and close cases).
BUG=43274
TEST=Manual. Launch Chrome on Windows, create two browser windows, minimize "a" window, quit. Relaunch, expect "a" to be minimized.
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=98679
Review URL: http://codereview.chromium.org/7748036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99077 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget')
-rw-r--r-- | views/widget/native_widget_gtk.cc | 17 | ||||
-rw-r--r-- | views/widget/native_widget_gtk.h | 7 | ||||
-rw-r--r-- | views/widget/native_widget_private.h | 15 | ||||
-rw-r--r-- | views/widget/native_widget_views.cc | 8 | ||||
-rw-r--r-- | views/widget/native_widget_views.h | 7 | ||||
-rw-r--r-- | views/widget/native_widget_win.cc | 34 | ||||
-rw-r--r-- | views/widget/native_widget_win.h | 7 | ||||
-rw-r--r-- | views/widget/widget.cc | 69 | ||||
-rw-r--r-- | views/widget/widget.h | 23 | ||||
-rw-r--r-- | views/widget/widget_delegate.cc | 21 | ||||
-rw-r--r-- | views/widget/widget_delegate.h | 12 |
11 files changed, 123 insertions, 97 deletions
diff --git a/views/widget/native_widget_gtk.cc b/views/widget/native_widget_gtk.cc index dd57b00..3db5d91 100644 --- a/views/widget/native_widget_gtk.cc +++ b/views/widget/native_widget_gtk.cc @@ -1004,8 +1004,9 @@ void NativeWidgetGtk::CenterWindow(const gfx::Size& size) { SetBoundsConstrained(bounds, NULL); } -void NativeWidgetGtk::GetWindowBoundsAndMaximizedState(gfx::Rect* bounds, - bool* maximized) const { +void NativeWidgetGtk::GetWindowPlacement( + gfx::Rect* bounds, + ui::WindowShowState* show_state) const { // Do nothing for now. ChromeOS isn't yet saving window placement. } @@ -1186,9 +1187,9 @@ void NativeWidgetGtk::ShowMaximizedWithBounds( Show(); } -void NativeWidgetGtk::ShowWithState(ShowState state) { +void NativeWidgetGtk::ShowWithWindowState(ui::WindowShowState show_state) { // No concept of maximization (yet) on ChromeOS. - if (state == internal::NativeWidgetPrivate::SHOW_INACTIVE) + if (show_state == ui::SHOW_STATE_INACTIVE) gtk_window_set_focus_on_map(GetNativeWindow(), false); gtk_widget_show(GetNativeView()); } @@ -2076,10 +2077,14 @@ void NativeWidgetGtk::SaveWindowPosition() { if (!GetWidget()->widget_delegate()) return; - bool maximized = window_state_ & GDK_WINDOW_STATE_MAXIMIZED; + ui::WindowShowState show_state = ui::SHOW_STATE_NORMAL; + if (IsMaximized()) + show_state = ui::SHOW_STATE_MAXIMIZED; + else if (IsMinimized()) + show_state = ui::SHOW_STATE_MINIMIZED; GetWidget()->widget_delegate()->SaveWindowPlacement( GetWidget()->GetWindowScreenBounds(), - maximized); + show_state); } //////////////////////////////////////////////////////////////////////////////// diff --git a/views/widget/native_widget_gtk.h b/views/widget/native_widget_gtk.h index 659db5f..798d035 100644 --- a/views/widget/native_widget_gtk.h +++ b/views/widget/native_widget_gtk.h @@ -166,8 +166,9 @@ class VIEWS_EXPORT NativeWidgetGtk : public internal::NativeWidgetPrivate, virtual bool HasMouseCapture() const OVERRIDE; virtual InputMethod* CreateInputMethod() OVERRIDE; virtual void CenterWindow(const gfx::Size& size) OVERRIDE; - virtual void GetWindowBoundsAndMaximizedState(gfx::Rect* bounds, - bool* maximized) const OVERRIDE; + virtual void GetWindowPlacement( + gfx::Rect* bounds, + ui::WindowShowState* show_state) const OVERRIDE; virtual void SetWindowTitle(const std::wstring& title) OVERRIDE; virtual void SetWindowIcons(const SkBitmap& window_icon, const SkBitmap& app_icon) OVERRIDE; @@ -192,7 +193,7 @@ class VIEWS_EXPORT NativeWidgetGtk : public internal::NativeWidgetPrivate, virtual void Hide() OVERRIDE; virtual void ShowMaximizedWithBounds( const gfx::Rect& restored_bounds) OVERRIDE; - virtual void ShowWithState(ShowState state) OVERRIDE; + virtual void ShowWithWindowState(ui::WindowShowState window_state) OVERRIDE; virtual bool IsVisible() const OVERRIDE; virtual void Activate() OVERRIDE; virtual void Deactivate() OVERRIDE; diff --git a/views/widget/native_widget_private.h b/views/widget/native_widget_private.h index df332cf..dbeab12 100644 --- a/views/widget/native_widget_private.h +++ b/views/widget/native_widget_private.h @@ -137,10 +137,11 @@ class VIEWS_EXPORT NativeWidgetPrivate : public NativeWidget, // Centers the window and sizes it to the specified size. virtual void CenterWindow(const gfx::Size& size) = 0; - // Retrieves the window's current restored bounds and maximized state, for + // Retrieves the window's current restored bounds and "show" state, for // persisting. - virtual void GetWindowBoundsAndMaximizedState(gfx::Rect* bounds, - bool* maximized) const = 0; + virtual void GetWindowPlacement( + gfx::Rect* bounds, + ui::WindowShowState* show_state) const = 0; // Sets the NativeWindow title. virtual void SetWindowTitle(const std::wstring& title) = 0; @@ -156,12 +157,6 @@ class VIEWS_EXPORT NativeWidgetPrivate : public NativeWidget, virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) = 0; virtual void SetAccessibleState(ui::AccessibilityTypes::State state) = 0; - enum ShowState { - SHOW_RESTORED, - SHOW_MAXIMIZED, - SHOW_INACTIVE - }; - // Makes the NativeWindow modal. virtual void BecomeModal() = 0; @@ -184,7 +179,7 @@ class VIEWS_EXPORT NativeWidgetPrivate : public NativeWidget, // Invoked if the initial show should maximize the window. |restored_bounds| // is the bounds of the window when not maximized. virtual void ShowMaximizedWithBounds(const gfx::Rect& restored_bounds) = 0; - virtual void ShowWithState(ShowState state) = 0; + virtual void ShowWithWindowState(ui::WindowShowState show_state) = 0; virtual bool IsVisible() const = 0; virtual void Activate() = 0; virtual void Deactivate() = 0; diff --git a/views/widget/native_widget_views.cc b/views/widget/native_widget_views.cc index eb7047f..017c80c 100644 --- a/views/widget/native_widget_views.cc +++ b/views/widget/native_widget_views.cc @@ -251,11 +251,11 @@ void NativeWidgetViews::CenterWindow(const gfx::Size& size) { size.width(), size.height()); } -void NativeWidgetViews::GetWindowBoundsAndMaximizedState( +void NativeWidgetViews::GetWindowPlacement( gfx::Rect* bounds, - bool* maximized) const { + ui::WindowShowState* show_state) const { *bounds = GetView()->bounds(); - *maximized = false; + *show_state = ui::SHOW_STATE_NORMAL; } void NativeWidgetViews::SetWindowTitle(const std::wstring& title) { @@ -349,7 +349,7 @@ void NativeWidgetViews::Hide() { ReleaseMouseCapture(); } -void NativeWidgetViews::ShowWithState(ShowState state) { +void NativeWidgetViews::ShowWithWindowState(ui::WindowShowState show_state) { Show(); } diff --git a/views/widget/native_widget_views.h b/views/widget/native_widget_views.h index 2095d12..ceaccc4 100644 --- a/views/widget/native_widget_views.h +++ b/views/widget/native_widget_views.h @@ -78,8 +78,9 @@ class VIEWS_EXPORT NativeWidgetViews : public internal::NativeWidgetPrivate { virtual bool HasMouseCapture() const OVERRIDE; virtual InputMethod* CreateInputMethod() OVERRIDE; virtual void CenterWindow(const gfx::Size& size) OVERRIDE; - virtual void GetWindowBoundsAndMaximizedState(gfx::Rect* bounds, - bool* maximized) const OVERRIDE; + virtual void GetWindowPlacement( + gfx::Rect* bounds, + ui::WindowShowState* show_state) const OVERRIDE; virtual void SetWindowTitle(const std::wstring& title) OVERRIDE; virtual void SetWindowIcons(const SkBitmap& window_icon, const SkBitmap& app_icon) OVERRIDE; @@ -104,7 +105,7 @@ class VIEWS_EXPORT NativeWidgetViews : public internal::NativeWidgetPrivate { virtual void Hide() OVERRIDE; virtual void ShowMaximizedWithBounds( const gfx::Rect& restored_bounds) OVERRIDE; - virtual void ShowWithState(ShowState state) OVERRIDE; + virtual void ShowWithWindowState(ui::WindowShowState window_state) OVERRIDE; virtual bool IsVisible() const OVERRIDE; virtual void Activate() OVERRIDE; virtual void Deactivate() OVERRIDE; diff --git a/views/widget/native_widget_win.cc b/views/widget/native_widget_win.cc index 0e459c7..173ad25 100644 --- a/views/widget/native_widget_win.cc +++ b/views/widget/native_widget_win.cc @@ -627,11 +627,12 @@ void NativeWidgetWin::CenterWindow(const gfx::Size& size) { ui::CenterAndSizeWindow(parent, GetNativeView(), size, false); } -void NativeWidgetWin::GetWindowBoundsAndMaximizedState(gfx::Rect* bounds, - bool* maximized) const { +void NativeWidgetWin::GetWindowPlacement( + gfx::Rect* bounds, + ui::WindowShowState* show_state) const { WINDOWPLACEMENT wp; wp.length = sizeof(wp); - const bool succeeded = !!GetWindowPlacement(GetNativeView(), &wp); + const bool succeeded = !!::GetWindowPlacement(GetNativeView(), &wp); DCHECK(succeeded); if (bounds != NULL) { @@ -646,8 +647,14 @@ void NativeWidgetWin::GetWindowBoundsAndMaximizedState(gfx::Rect* bounds, mi.rcWork.top - mi.rcMonitor.top); } - if (maximized != NULL) - *maximized = (wp.showCmd == SW_SHOWMAXIMIZED); + if (show_state != NULL) { + if (wp.showCmd == SW_SHOWMAXIMIZED) + *show_state = ui::SHOW_STATE_MAXIMIZED; + else if (wp.showCmd == SW_SHOWMINIMIZED) + *show_state = ui::SHOW_STATE_MINIMIZED; + else + *show_state = ui::SHOW_STATE_NORMAL; + } } void NativeWidgetWin::SetWindowTitle(const std::wstring& title) { @@ -749,7 +756,7 @@ gfx::Rect NativeWidgetWin::GetRestoredBounds() const { return gfx::Rect(saved_window_info_.window_rect); gfx::Rect bounds; - GetWindowBoundsAndMaximizedState(&bounds, NULL); + GetWindowPlacement(&bounds, NULL); return bounds; } @@ -865,15 +872,18 @@ void NativeWidgetWin::ShowMaximizedWithBounds( SetWindowPlacement(hwnd(), &placement); } -void NativeWidgetWin::ShowWithState(ShowState state) { +void NativeWidgetWin::ShowWithWindowState(ui::WindowShowState show_state) { DWORD native_show_state; - switch (state) { - case SHOW_INACTIVE: + switch (show_state) { + case ui::SHOW_STATE_INACTIVE: native_show_state = SW_SHOWNOACTIVATE; break; - case SHOW_MAXIMIZED: + case ui::SHOW_STATE_MAXIMIZED: native_show_state = SW_SHOWMAXIMIZED; break; + case ui::SHOW_STATE_MINIMIZED: + native_show_state = SW_SHOWMINIMIZED; + break; default: native_show_state = GetShowState(); break; @@ -2164,8 +2174,10 @@ void NativeWidgetWin::SetInitParams(const Widget::InitParams& params) { // Set type-independent style attributes. if (params.child) style |= WS_CHILD | WS_VISIBLE; - if (params.maximize) + if (params.show_state == ui::SHOW_STATE_MAXIMIZED) style |= WS_MAXIMIZE; + if (params.show_state == ui::SHOW_STATE_MINIMIZED) + style |= WS_MINIMIZE; if (!params.accept_events) ex_style |= WS_EX_TRANSPARENT; if (!params.can_activate) diff --git a/views/widget/native_widget_win.h b/views/widget/native_widget_win.h index c29d354..3cfa9c6 100644 --- a/views/widget/native_widget_win.h +++ b/views/widget/native_widget_win.h @@ -209,8 +209,9 @@ class VIEWS_EXPORT NativeWidgetWin : public ui::WindowImpl, virtual bool HasMouseCapture() const OVERRIDE; virtual InputMethod* CreateInputMethod() OVERRIDE; virtual void CenterWindow(const gfx::Size& size) OVERRIDE; - virtual void GetWindowBoundsAndMaximizedState(gfx::Rect* bounds, - bool* maximized) const OVERRIDE; + virtual void GetWindowPlacement( + gfx::Rect* bounds, + ui::WindowShowState* show_state) const OVERRIDE; virtual void SetWindowTitle(const std::wstring& title) OVERRIDE; virtual void SetWindowIcons(const SkBitmap& window_icon, const SkBitmap& app_icon) OVERRIDE; @@ -235,7 +236,7 @@ class VIEWS_EXPORT NativeWidgetWin : public ui::WindowImpl, virtual void Hide() OVERRIDE; virtual void ShowMaximizedWithBounds( const gfx::Rect& restored_bounds) OVERRIDE; - virtual void ShowWithState(ShowState state) OVERRIDE; + virtual void ShowWithWindowState(ui::WindowShowState show_state) OVERRIDE; virtual bool IsVisible() const OVERRIDE; virtual void Activate() OVERRIDE; virtual void Deactivate() OVERRIDE; diff --git a/views/widget/widget.cc b/views/widget/widget.cc index 80ca73d..8ed6c8d 100644 --- a/views/widget/widget.cc +++ b/views/widget/widget.cc @@ -109,7 +109,7 @@ Widget::InitParams::InitParams() ownership(NATIVE_WIDGET_OWNS_WIDGET), mirror_origin_in_rtl(false), has_dropshadow(false), - maximize(false), + show_state(ui::SHOW_STATE_DEFAULT), double_buffer(false), parent(NULL), parent_widget(NULL), @@ -129,7 +129,7 @@ Widget::InitParams::InitParams(Type type) ownership(NATIVE_WIDGET_OWNS_WIDGET), mirror_origin_in_rtl(false), has_dropshadow(false), - maximize(false), + show_state(ui::SHOW_STATE_DEFAULT), double_buffer(false), parent(NULL), parent_widget(NULL), @@ -158,10 +158,11 @@ Widget::Widget() frame_type_(FRAME_TYPE_DEFAULT), disable_inactive_rendering_(false), widget_closed_(false), - saved_maximized_state_(false), + saved_show_state_(ui::SHOW_STATE_DEFAULT), minimum_size_(100, 100), focus_on_creation_(true), - is_top_level_(false) { + is_top_level_(false), + native_widget_initialized_(false) { } Widget::~Widget() { @@ -311,10 +312,13 @@ void Widget::Init(const InitParams& params) { non_client_view_->set_client_view(widget_delegate_->CreateClientView(this)); SetContentsView(non_client_view_); SetInitialBounds(params.bounds); - if (params.maximize) + if (params.show_state == ui::SHOW_STATE_MAXIMIZED) Maximize(); + else if (params.show_state == ui::SHOW_STATE_MINIMIZED) + Minimize(); UpdateWindowTitle(); } + native_widget_initialized_ = true; } // Unconverted methods (see header) -------------------------------------------- @@ -446,7 +450,7 @@ void Widget::Close() { if (non_client_view_) can_close = non_client_view_->CanClose(); if (can_close) { - SaveWindowPosition(); + SaveWindowPlacement(); // During tear-down the top-level focus manager becomes unavailable to // GTK tabbed panes and their children, so normal deregistration via @@ -473,17 +477,16 @@ void Widget::EnableClose(bool enable) { void Widget::Show() { if (non_client_view_) { - if (saved_maximized_state_ && !initial_restored_bounds_.IsEmpty()) { + if (saved_show_state_ == ui::SHOW_STATE_MAXIMIZED && + !initial_restored_bounds_.IsEmpty()) { native_widget_->ShowMaximizedWithBounds(initial_restored_bounds_); } else { - native_widget_->ShowWithState(saved_maximized_state_ ? - internal::NativeWidgetPrivate::SHOW_MAXIMIZED : - internal::NativeWidgetPrivate::SHOW_RESTORED); + native_widget_->ShowWithWindowState(saved_show_state_); } - // |saved_maximized_state_| only applies the first time the window is shown. - // If we don't reset the value the window will be shown maximized every time + // |saved_show_state_| only applies the first time the window is shown. + // If we don't reset the value the window may be shown maximized every time // it is subsequently shown after being hidden. - saved_maximized_state_ = false; + saved_show_state_ = ui::SHOW_STATE_NORMAL; } else { native_widget_->Show(); } @@ -494,14 +497,16 @@ void Widget::Hide() { } void Widget::ShowInactive() { - // If this gets called with saved_maximized_state_ == true, call SetBounds() - // with the restored bounds to set the correct size. This normally should - // not happen, but if it does we should avoid showing unsized windows. - if (saved_maximized_state_ && !initial_restored_bounds_.IsEmpty()) { + // If this gets called with saved_show_state_ == ui::SHOW_STATE_MAXIMIZED, + // call SetBounds()with the restored bounds to set the correct size. This + // normally should not happen, but if it does we should avoid showing unsized + // windows. + if (saved_show_state_ == ui::SHOW_STATE_MAXIMIZED && + !initial_restored_bounds_.IsEmpty()) { SetBounds(initial_restored_bounds_); - saved_maximized_state_ = false; + saved_show_state_ = ui::SHOW_STATE_NORMAL; } - native_widget_->ShowWithState(internal::NativeWidgetPrivate::SHOW_INACTIVE); + native_widget_->ShowWithWindowState(ui::SHOW_STATE_INACTIVE); } void Widget::Activate() { @@ -825,7 +830,7 @@ void Widget::EnableInactiveRendering() { void Widget::OnNativeWidgetActivationChanged(bool active) { if (!active) { - SaveWindowPosition(); + SaveWindowPlacement(); // Close any open menus. MenuController* menu_controller = MenuController::GetActiveInstance(); @@ -886,6 +891,12 @@ gfx::Size Widget::GetMinimumSize() { void Widget::OnNativeWidgetSizeChanged(const gfx::Size& new_size) { root_view_->SetSize(new_size); + + // Size changed notifications can fire prior to full initialization + // i.e. during session restore. Avoid saving session state during these + // startup procedures. + if (native_widget_initialized_) + SaveWindowPlacement(); } void Widget::OnNativeWidgetBeginUserBoundsChange() { @@ -1055,7 +1066,7 @@ bool Widget::ShouldReleaseCaptureOnMouseReleased() const { return true; } -void Widget::SaveWindowPosition() { +void Widget::SaveWindowPlacement() { // The window delegate does the actual saving for us. It seems like (judging // by go/crash) that in some circumstances we can end up here after // WM_DESTROY, at which point the window delegate is likely gone. So just @@ -1063,10 +1074,10 @@ void Widget::SaveWindowPosition() { if (!widget_delegate_) return; - bool maximized = false; + ui::WindowShowState show_state = ui::SHOW_STATE_NORMAL; gfx::Rect bounds; - native_widget_->GetWindowBoundsAndMaximizedState(&bounds, &maximized); - widget_delegate_->SaveWindowPlacement(bounds, maximized); + native_widget_->GetWindowPlacement(&bounds, &show_state); + widget_delegate_->SaveWindowPlacement(bounds, show_state); } void Widget::SetInitialBounds(const gfx::Rect& bounds) { @@ -1074,8 +1085,8 @@ void Widget::SetInitialBounds(const gfx::Rect& bounds) { return; gfx::Rect saved_bounds; - if (GetSavedBounds(&saved_bounds, &saved_maximized_state_)) { - if (saved_maximized_state_) { + if (GetSavedWindowPlacement(&saved_bounds, &saved_show_state_)) { + if (saved_show_state_ == ui::SHOW_STATE_MAXIMIZED) { // If we're going to maximize, wait until Show is invoked to set the // bounds. That way we avoid a noticable resize. initial_restored_bounds_ = saved_bounds; @@ -1094,17 +1105,17 @@ void Widget::SetInitialBounds(const gfx::Rect& bounds) { } } -bool Widget::GetSavedBounds(gfx::Rect* bounds, bool* maximize) { +bool Widget::GetSavedWindowPlacement(gfx::Rect* bounds, + ui::WindowShowState* show_state) { // First we obtain the window's saved show-style and store it. We need to do // this here, rather than in Show() because by the time Show() is called, // the window's size will have been reset (below) and the saved maximized // state will have been lost. Sadly there's no way to tell on Windows when // a window is restored from maximized state, so we can't more accurately // track maximized state independently of sizing information. - widget_delegate_->GetSavedMaximizedState(maximize); // Restore the window's placement from the controller. - if (widget_delegate_->GetSavedWindowBounds(bounds)) { + if (widget_delegate_->GetSavedWindowPlacement(bounds, show_state)) { if (!widget_delegate_->ShouldRestoreWindowSize()) { bounds->set_size(non_client_view_->GetPreferredSize()); } else { diff --git a/views/widget/widget.h b/views/widget/widget.h index a85b619..dd23dd6 100644 --- a/views/widget/widget.h +++ b/views/widget/widget.h @@ -12,6 +12,7 @@ #include "base/memory/scoped_ptr.h" #include "base/observer_list.h" #include "ui/base/accessibility/accessibility_types.h" +#include "ui/base/ui_base_types.h" #include "ui/gfx/native_widget_types.h" #include "ui/gfx/rect.h" #include "views/focus/focus_manager.h" @@ -144,8 +145,8 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, Ownership ownership; bool mirror_origin_in_rtl; bool has_dropshadow; - // Whether the widget should be maximized. - bool maximize; + // Whether the widget should be maximized or minimized. + ui::WindowShowState show_state; // Should the widget be double buffered? Default is false. bool double_buffer; gfx::NativeView parent; @@ -635,16 +636,17 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, // Returns whether capture should be released on mouse release. virtual bool ShouldReleaseCaptureOnMouseReleased() const; - // Persists the window's restored position and maximized state using the + // Persists the window's restored position and "show" state using the // window delegate. - void SaveWindowPosition(); + void SaveWindowPlacement(); // Sizes and positions the window just after it is created. void SetInitialBounds(const gfx::Rect& bounds); - // Returns the bounds and maximized state from the delegate. Returns true if + // Returns the bounds and "show" state from the delegate. Returns true if // the delegate wants to use a specified bounds. - bool GetSavedBounds(gfx::Rect* bounds, bool* maximize); + bool GetSavedWindowPlacement(gfx::Rect* bounds, + ui::WindowShowState* show_state); // Sets a different InputMethod instance to this widget. The instance // must not be initialized, the ownership will be assumed by the widget. @@ -703,12 +705,12 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, // Set to true if the widget is in the process of closing. bool widget_closed_; - // The saved maximized state for this window. See note in SetInitialBounds + // The saved "show" state for this window. See note in SetInitialBounds // that explains why we save this. - bool saved_maximized_state_; + ui::WindowShowState saved_show_state_; // The restored bounds used for the initial show. This is only used if - // |saved_maximized_state_| is true. + // |saved_show_state_| is maximized. gfx::Rect initial_restored_bounds_; // The smallest size the window can be. @@ -727,6 +729,9 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, // Factory used to create Compositors. Settable by tests. static ui::Compositor*(*compositor_factory_)(); + // Tracks whether native widget has been initialized. + bool native_widget_initialized_; + DISALLOW_COPY_AND_ASSIGN(Widget); }; diff --git a/views/widget/widget_delegate.cc b/views/widget/widget_delegate.cc index d031295..25cb54a 100644 --- a/views/widget/widget_delegate.cc +++ b/views/widget/widget_delegate.cc @@ -98,31 +98,24 @@ std::wstring WidgetDelegate::GetWindowName() const { } void WidgetDelegate::SaveWindowPlacement(const gfx::Rect& bounds, - bool maximized) { + ui::WindowShowState show_state) { std::wstring window_name = GetWindowName(); if (!ViewsDelegate::views_delegate || window_name.empty()) return; ViewsDelegate::views_delegate->SaveWindowPlacement( - GetWidget(), window_name, bounds, maximized); + GetWidget(), window_name, bounds, show_state); } -bool WidgetDelegate::GetSavedWindowBounds(gfx::Rect* bounds) const { +bool WidgetDelegate::GetSavedWindowPlacement( + gfx::Rect* bounds, + ui::WindowShowState* show_state) const { std::wstring window_name = GetWindowName(); if (!ViewsDelegate::views_delegate || window_name.empty()) return false; - return ViewsDelegate::views_delegate->GetSavedWindowBounds( - window_name, bounds); -} - -bool WidgetDelegate::GetSavedMaximizedState(bool* maximized) const { - std::wstring window_name = GetWindowName(); - if (!ViewsDelegate::views_delegate || window_name.empty()) - return false; - - return ViewsDelegate::views_delegate->GetSavedMaximizedState( - window_name, maximized); + return ViewsDelegate::views_delegate->GetSavedWindowPlacement( + window_name, bounds, show_state); } bool WidgetDelegate::ShouldRestoreWindowSize() const { diff --git a/views/widget/widget_delegate.h b/views/widget/widget_delegate.h index 85485e6..5c73d4d 100644 --- a/views/widget/widget_delegate.h +++ b/views/widget/widget_delegate.h @@ -10,6 +10,7 @@ #include "base/memory/scoped_ptr.h" #include "ui/base/accessibility/accessibility_types.h" +#include "ui/base/ui_base_types.h" #include "views/view.h" class SkBitmap; @@ -97,15 +98,16 @@ class VIEWS_EXPORT WidgetDelegate { // state restoration. virtual std::wstring GetWindowName() const; - // Saves the window's bounds and maximized states. By default this uses the + // Saves the window's bounds and "show" state. By default this uses the // process' local state keyed by window name (See GetWindowName above). This // behavior can be overridden to provide additional functionality. - virtual void SaveWindowPlacement(const gfx::Rect& bounds, bool maximized); + virtual void SaveWindowPlacement(const gfx::Rect& bounds, + ui::WindowShowState show_state); - // Retrieves the window's bounds and maximized states. + // Retrieves the window's bounds and "show" states. // This behavior can be overridden to provide additional functionality. - virtual bool GetSavedWindowBounds(gfx::Rect* bounds) const; - virtual bool GetSavedMaximizedState(bool* maximized) const; + virtual bool GetSavedWindowPlacement(gfx::Rect* bounds, + ui::WindowShowState* show_state) const; // Returns true if the window's size should be restored. If this is false, // only the window's origin is restored and the window is given its |