summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/chromeos/frame/browser_view.cc7
-rw-r--r--chrome/browser/chromeos/frame/browser_view.h4
-rw-r--r--chrome/browser/chromeos/frame/panel_browser_view.cc18
-rw-r--r--chrome/browser/chromeos/frame/panel_browser_view.h5
-rw-r--r--chrome/browser/sessions/session_restore.cc20
-rw-r--r--chrome/browser/sessions/session_service.cc4
-rw-r--r--chrome/browser/ui/browser_browsertest.cc14
-rw-r--r--chrome/browser/ui/panels/panel_browser_view.cc5
-rw-r--r--chrome/browser/ui/panels/panel_browser_view.h4
-rw-r--r--chrome/browser/ui/views/accessibility_event_router_views_unittest.cc12
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc12
-rw-r--r--chrome/browser/ui/views/chrome_views_delegate.cc30
-rw-r--r--chrome/browser/ui/views/chrome_views_delegate.h10
-rw-r--r--chrome/browser/ui/views/frame/browser_frame.cc3
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc28
-rw-r--r--chrome/browser/ui/views/frame/browser_view.h7
-rw-r--r--chrome/browser/ui/views/menu_model_adapter_test.cc13
-rw-r--r--ui/base/ui_base_types.h3
-rw-r--r--views/desktop/desktop_views_delegate.cc12
-rw-r--r--views/desktop/desktop_views_delegate.h10
-rw-r--r--views/desktop/desktop_window_view.cc2
-rw-r--r--views/test/test_views_delegate.cc13
-rw-r--r--views/test/test_views_delegate.h11
-rw-r--r--views/views_delegate.h22
-rw-r--r--views/widget/native_widget_gtk.cc17
-rw-r--r--views/widget/native_widget_gtk.h7
-rw-r--r--views/widget/native_widget_private.h15
-rw-r--r--views/widget/native_widget_views.cc8
-rw-r--r--views/widget/native_widget_views.h7
-rw-r--r--views/widget/native_widget_win.cc34
-rw-r--r--views/widget/native_widget_win.h7
-rw-r--r--views/widget/widget.cc70
-rw-r--r--views/widget/widget.h23
-rw-r--r--views/widget/widget_delegate.cc21
-rw-r--r--views/widget/widget_delegate.h12
35 files changed, 224 insertions, 266 deletions
diff --git a/chrome/browser/chromeos/frame/browser_view.cc b/chrome/browser/chromeos/frame/browser_view.cc
index 9efb707..c25ccbd 100644
--- a/chrome/browser/chromeos/frame/browser_view.cc
+++ b/chrome/browser/chromeos/frame/browser_view.cc
@@ -449,9 +449,7 @@ void BrowserView::ChildPreferredSizeChanged(View* child) {
Layout();
}
-bool BrowserView::GetSavedWindowPlacement(
- gfx::Rect* bounds,
- ui::WindowShowState* show_state) const {
+bool BrowserView::GetSavedWindowBounds(gfx::Rect* bounds) const {
if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kChromeosFrame)) {
// Typically we don't request a full screen size. This means we'll request a
// non-full screen size, layout/paint at that size, then the window manager
@@ -459,10 +457,9 @@ bool BrowserView::GetSavedWindowPlacement(
// resize/paint. To avoid this we always request a full screen size.
*bounds = gfx::Screen::GetMonitorWorkAreaNearestWindow(
GTK_WIDGET(GetWidget()->GetNativeWindow()));
- *show_state = ui::SHOW_STATE_NORMAL;
return true;
}
- return ::BrowserView::GetSavedWindowPlacement(bounds, show_state);
+ return ::BrowserView::GetSavedWindowBounds(bounds);
}
void BrowserView::Cut() {
diff --git a/chrome/browser/chromeos/frame/browser_view.h b/chrome/browser/chromeos/frame/browser_view.h
index b938e21..9d7ae95 100644
--- a/chrome/browser/chromeos/frame/browser_view.h
+++ b/chrome/browser/chromeos/frame/browser_view.h
@@ -61,9 +61,7 @@ class BrowserView : public ::BrowserView,
virtual void FocusChromeOSStatus() OVERRIDE;
virtual views::LayoutManager* CreateLayoutManager() const OVERRIDE;
virtual void ChildPreferredSizeChanged(View* child) OVERRIDE;
- virtual bool GetSavedWindowPlacement(
- gfx::Rect* bounds,
- ui::WindowShowState* show_state) const OVERRIDE;
+ virtual bool GetSavedWindowBounds(gfx::Rect* bounds) const OVERRIDE;
virtual void Cut() OVERRIDE;
virtual void Copy() OVERRIDE;
virtual void Paste() OVERRIDE;
diff --git a/chrome/browser/chromeos/frame/panel_browser_view.cc b/chrome/browser/chromeos/frame/panel_browser_view.cc
index de39b0e..fba8fa8 100644
--- a/chrome/browser/chromeos/frame/panel_browser_view.cc
+++ b/chrome/browser/chromeos/frame/panel_browser_view.cc
@@ -110,16 +110,16 @@ WindowOpenDisposition PanelBrowserView::GetDispositionForPopupBounds(
return chromeos::BrowserView::DispositionForPopupBounds(bounds);
}
-bool PanelBrowserView::GetSavedWindowPlacement(
- gfx::Rect* bounds,
- ui::WindowShowState* show_state) const {
- bool result = ::BrowserView::GetSavedWindowPlacement(bounds, show_state);
- if (result) {
+bool PanelBrowserView::GetSavedWindowBounds(gfx::Rect* bounds) const {
+ bool res = ::BrowserView::GetSavedWindowBounds(bounds);
+ if (res)
LimitBounds(bounds);
- // Panels have no maximized state.
- *show_state = ui::SHOW_STATE_NORMAL;
- }
- return result;
+ return res;
+}
+
+bool PanelBrowserView::GetSavedMaximizedState(bool* maximized) const {
+ // Panels have no maximized state.
+ return false;
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/chromeos/frame/panel_browser_view.h b/chrome/browser/chromeos/frame/panel_browser_view.h
index 99ec9ab..819419e 100644
--- a/chrome/browser/chromeos/frame/panel_browser_view.h
+++ b/chrome/browser/chromeos/frame/panel_browser_view.h
@@ -35,9 +35,8 @@ class PanelBrowserView : public ::BrowserView,
virtual void UpdateTitleBar() OVERRIDE;
virtual WindowOpenDisposition GetDispositionForPopupBounds(
const gfx::Rect& bounds) OVERRIDE;
- virtual bool GetSavedWindowPlacement(
- gfx::Rect* bounds,
- ui::WindowShowState* show_state) const OVERRIDE;
+ virtual bool GetSavedWindowBounds(gfx::Rect* bounds) const OVERRIDE;
+ virtual bool GetSavedMaximizedState(bool* maximized) const OVERRIDE;
// views::Widget::Observer overrides.
virtual void OnWidgetActivationChanged(views::Widget* widget,
diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc
index a7fe098..c4c5b29 100644
--- a/chrome/browser/sessions/session_restore.cc
+++ b/chrome/browser/sessions/session_restore.cc
@@ -598,15 +598,6 @@ class SessionRestoreImpl : public NotificationObserver {
// tabbed browsers exist.
Browser* last_browser = NULL;
bool has_tabbed_browser = false;
-
- // Determine if there is a visible window.
- bool has_visible_browser = false;
- for (std::vector<SessionWindow*>::iterator i = windows->begin();
- i != windows->end(); ++i) {
- if ((*i)->show_state != ui::SHOW_STATE_MINIMIZED)
- has_visible_browser = true;
- }
-
for (std::vector<SessionWindow*>::iterator i = windows->begin();
i != windows->end(); ++i) {
Browser* browser = NULL;
@@ -622,15 +613,10 @@ class SessionRestoreImpl : public NotificationObserver {
chromeos::BootTimesLoader::Get()->AddLoginTimeMarker(
"SessionRestore-CreateRestoredBrowser-Start", false);
#endif
- // Show the first window if none are visible.
- ui::WindowShowState show_state = (*i)->show_state;
- if (!has_visible_browser) {
- show_state = ui::SHOW_STATE_NORMAL;
- has_visible_browser = true;
- }
-
browser = CreateRestoredBrowser(
- static_cast<Browser::Type>((*i)->type), (*i)->bounds, show_state);
+ static_cast<Browser::Type>((*i)->type),
+ (*i)->bounds,
+ (*i)->show_state);
#if defined(OS_CHROMEOS)
chromeos::BootTimesLoader::Get()->AddLoginTimeMarker(
"SessionRestore-CreateRestoredBrowser-End", false);
diff --git a/chrome/browser/sessions/session_service.cc b/chrome/browser/sessions/session_service.cc
index 8e3f1d73..dbb0f94 100644
--- a/chrome/browser/sessions/session_service.cc
+++ b/chrome/browser/sessions/session_service.cc
@@ -970,11 +970,9 @@ bool SessionService::CreateTabsAndWindows(
payload.y,
payload.w,
payload.h);
- // SHOW_STATE_INACTIVE is not persisted.
ui::WindowShowState show_state = ui::SHOW_STATE_NORMAL;
if (payload.show_state > ui::SHOW_STATE_DEFAULT &&
- payload.show_state < ui::SHOW_STATE_MAX &&
- payload.show_state != ui::SHOW_STATE_INACTIVE) {
+ payload.show_state < ui::SHOW_STATE_MAX) {
show_state = static_cast<ui::WindowShowState>(payload.show_state);
} else {
NOTREACHED();
diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc
index 61b2020..9735848 100644
--- a/chrome/browser/ui/browser_browsertest.cc
+++ b/chrome/browser/ui/browser_browsertest.cc
@@ -974,20 +974,6 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, StartMaximized) {
}
}
-// Makes sure the browser doesn't crash when
-// set_show_state(ui::SHOW_STATE_MINIMIZED) has been invoked.
-IN_PROC_BROWSER_TEST_F(BrowserTest, StartMinimized) {
- // Can't test TYPE_PANEL as they are currently created differently (and can't
- // end up minimized).
- Browser::Type types[] = { Browser::TYPE_TABBED, Browser::TYPE_POPUP };
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(types); ++i) {
- Browser* min_browser = new Browser(types[i], browser()->profile());
- min_browser->set_show_state(ui::SHOW_STATE_MINIMIZED);
- min_browser->InitBrowserWindow();
- AddBlankTabAndShow(min_browser);
- }
-}
-
// TODO(ben): this test was never enabled. It has bit-rotted since being added.
// It originally lived in browser_unittest.cc, but has been moved here to make
// room for real browser unit tests.
diff --git a/chrome/browser/ui/panels/panel_browser_view.cc b/chrome/browser/ui/panels/panel_browser_view.cc
index add7282..854d703 100644
--- a/chrome/browser/ui/panels/panel_browser_view.cc
+++ b/chrome/browser/ui/panels/panel_browser_view.cc
@@ -107,11 +107,8 @@ void PanelBrowserView::UpdateTitleBar() {
GetFrameView()->UpdateTitleBar();
}
-bool PanelBrowserView::GetSavedWindowPlacement(
- gfx::Rect* bounds,
- ui::WindowShowState* show_state) const {
+bool PanelBrowserView::GetSavedWindowBounds(gfx::Rect* bounds) const {
*bounds = GetPanelBounds();
- *show_state = ui::SHOW_STATE_NORMAL;
return true;
}
diff --git a/chrome/browser/ui/panels/panel_browser_view.h b/chrome/browser/ui/panels/panel_browser_view.h
index c855fd0..5ecbfbe 100644
--- a/chrome/browser/ui/panels/panel_browser_view.h
+++ b/chrome/browser/ui/panels/panel_browser_view.h
@@ -56,9 +56,7 @@ class PanelBrowserView : public BrowserView,
virtual bool CanMaximize() const OVERRIDE;
virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
virtual void UpdateTitleBar() OVERRIDE;
- virtual bool GetSavedWindowPlacement(
- gfx::Rect* bounds,
- ui::WindowShowState* show_state) const OVERRIDE;
+ virtual bool GetSavedWindowBounds(gfx::Rect* bounds) const OVERRIDE;
virtual bool AcceleratorPressed(const views::Accelerator& accelerator)
OVERRIDE;
diff --git a/chrome/browser/ui/views/accessibility_event_router_views_unittest.cc b/chrome/browser/ui/views/accessibility_event_router_views_unittest.cc
index 3526b0a..24649bd 100644
--- a/chrome/browser/ui/views/accessibility_event_router_views_unittest.cc
+++ b/chrome/browser/ui/views/accessibility_event_router_views_unittest.cc
@@ -35,12 +35,14 @@ class AccessibilityViewsDelegate : public views::ViewsDelegate {
virtual void SaveWindowPlacement(const views::Widget* window,
const std::wstring& window_name,
const gfx::Rect& bounds,
- ui::WindowShowState show_state) OVERRIDE {
+ bool maximized) OVERRIDE {
}
- virtual bool GetSavedWindowPlacement(
- const std::wstring& window_name,
- gfx::Rect* bounds,
- ui::WindowShowState* show_state) const OVERRIDE {
+ virtual bool GetSavedWindowBounds(const std::wstring& window_name,
+ gfx::Rect* bounds) const OVERRIDE {
+ return false;
+ }
+ virtual bool GetSavedMaximizedState(const std::wstring& window_name,
+ bool* maximized) const OVERRIDE {
return false;
}
virtual void NotifyAccessibilityEvent(
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
index 0667da3..c033a9d 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
@@ -74,11 +74,13 @@ class ViewsDelegateImpl : public views::ViewsDelegate {
virtual void SaveWindowPlacement(const views::Widget* window,
const std::wstring& window_name,
const gfx::Rect& bounds,
- ui::WindowShowState show_state) OVERRIDE {}
- virtual bool GetSavedWindowPlacement(
- const std::wstring& window_name,
- gfx::Rect* bounds,
- ui::WindowShowState* show_state) const OVERRIDE {
+ bool maximized) OVERRIDE {}
+ virtual bool GetSavedWindowBounds(const std::wstring& window_name,
+ gfx::Rect* bounds) const OVERRIDE {
+ return false;
+ }
+ virtual bool GetSavedMaximizedState(const std::wstring& window_name,
+ bool* maximized) const OVERRIDE {
return false;
}
diff --git a/chrome/browser/ui/views/chrome_views_delegate.cc b/chrome/browser/ui/views/chrome_views_delegate.cc
index a6b7eef..a471e6f 100644
--- a/chrome/browser/ui/views/chrome_views_delegate.cc
+++ b/chrome/browser/ui/views/chrome_views_delegate.cc
@@ -61,7 +61,7 @@ views::View* ChromeViewsDelegate::GetDefaultParentView() {
void ChromeViewsDelegate::SaveWindowPlacement(const views::Widget* window,
const std::wstring& window_name,
const gfx::Rect& bounds,
- ui::WindowShowState show_state) {
+ bool maximized) {
PrefService* prefs = GetPrefsForWindow(window);
if (!prefs)
return;
@@ -73,8 +73,7 @@ void ChromeViewsDelegate::SaveWindowPlacement(const views::Widget* window,
window_preferences->SetInteger("top", bounds.y());
window_preferences->SetInteger("right", bounds.right());
window_preferences->SetInteger("bottom", bounds.bottom());
- window_preferences->SetBoolean("maximized",
- show_state == ui::SHOW_STATE_MAXIMIZED);
+ window_preferences->SetBoolean("maximized", maximized);
scoped_ptr<WindowSizer::MonitorInfoProvider> monitor_info_provider(
WindowSizer::CreateDefaultMonitorInfoProvider());
@@ -86,10 +85,8 @@ void ChromeViewsDelegate::SaveWindowPlacement(const views::Widget* window,
window_preferences->SetInteger("work_area_bottom", work_area.bottom());
}
-bool ChromeViewsDelegate::GetSavedWindowPlacement(
- const std::wstring& window_name,
- gfx::Rect* bounds,
- ui::WindowShowState* show_state) const {
+bool ChromeViewsDelegate::GetSavedWindowBounds(const std::wstring& window_name,
+ gfx::Rect* bounds) const {
PrefService* prefs = g_browser_process->local_state();
if (!prefs)
return false;
@@ -105,13 +102,22 @@ bool ChromeViewsDelegate::GetSavedWindowPlacement(
return false;
bounds->SetRect(left, top, right - left, bottom - top);
+ return true;
+}
+
+bool ChromeViewsDelegate::GetSavedMaximizedState(
+ const std::wstring& window_name,
+ bool* maximized) const {
+ PrefService* prefs = g_browser_process->local_state();
+ if (!prefs)
+ return false;
- bool maximized = false;
- if (dictionary)
- dictionary->GetBoolean("maximized", &maximized);
- *show_state = maximized ? ui::SHOW_STATE_MAXIMIZED : ui::SHOW_STATE_NORMAL;
+ DCHECK(prefs->FindPreference(WideToUTF8(window_name).c_str()));
+ const DictionaryValue* dictionary =
+ prefs->GetDictionary(WideToUTF8(window_name).c_str());
- return true;
+ return dictionary && dictionary->GetBoolean("maximized", maximized) &&
+ maximized;
}
void ChromeViewsDelegate::NotifyAccessibilityEvent(
diff --git a/chrome/browser/ui/views/chrome_views_delegate.h b/chrome/browser/ui/views/chrome_views_delegate.h
index a874348..fb3121e 100644
--- a/chrome/browser/ui/views/chrome_views_delegate.h
+++ b/chrome/browser/ui/views/chrome_views_delegate.h
@@ -25,11 +25,11 @@ class ChromeViewsDelegate : public views::ViewsDelegate {
virtual void SaveWindowPlacement(const views::Widget* window,
const std::wstring& window_name,
const gfx::Rect& bounds,
- ui::WindowShowState show_state) OVERRIDE;
- virtual bool GetSavedWindowPlacement(
- const std::wstring& window_name,
- gfx::Rect* bounds,
- ui::WindowShowState* show_state) const OVERRIDE;
+ bool maximized) OVERRIDE;
+ virtual bool GetSavedWindowBounds(const std::wstring& window_name,
+ gfx::Rect* bounds) const OVERRIDE;
+ virtual bool GetSavedMaximizedState(const std::wstring& window_name,
+ bool* maximized) const OVERRIDE;
virtual void NotifyAccessibilityEvent(
views::View* view, ui::AccessibilityTypes::Event event_type) OVERRIDE;
virtual void NotifyMenuItemFocused(
diff --git a/chrome/browser/ui/views/frame/browser_frame.cc b/chrome/browser/ui/views/frame/browser_frame.cc
index 31d2b67b..20f685a 100644
--- a/chrome/browser/ui/views/frame/browser_frame.cc
+++ b/chrome/browser/ui/views/frame/browser_frame.cc
@@ -48,7 +48,8 @@ void BrowserFrame::InitBrowserFrame() {
// Typed panel/popup can only return a size once the widget has been
// created.
params.bounds = browser_view_->browser()->GetSavedWindowBounds();
- params.show_state = browser_view_->browser()->GetSavedWindowShowState();
+ params.maximize = browser_view_->browser()->GetSavedWindowShowState() ==
+ ui::SHOW_STATE_MAXIMIZED;
}
Init(params);
#if defined(OS_CHROMEOS)
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 98dd3f5..59c87a7 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -790,7 +790,9 @@ bool BrowserView::IsMaximized() const {
}
bool BrowserView::IsMinimized() const {
- return frame_->IsMinimized();
+ // TODO(dhollowa): Add support for session restore of minimized state.
+ // http://crbug.com/43274
+ return false;
}
void BrowserView::SetFullscreen(bool fullscreen) {
@@ -1632,22 +1634,23 @@ std::wstring BrowserView::GetWindowName() const {
}
void BrowserView::SaveWindowPlacement(const gfx::Rect& bounds,
- ui::WindowShowState show_state) {
+ bool maximized) {
+ // TODO(dhollowa): Add support for session restore of minimized state.
+ // http://crbug.com/43274
+
// If IsFullscreen() is true, we've just changed into fullscreen mode, and
// we're catching the going-into-fullscreen sizing and positioning calls,
// which we want to ignore.
if (!IsFullscreen() && browser_->ShouldSaveWindowPlacement()) {
- WidgetDelegate::SaveWindowPlacement(bounds, show_state);
- browser_->SaveWindowPlacement(bounds, show_state);
+ WidgetDelegate::SaveWindowPlacement(bounds, maximized);
+ browser_->SaveWindowPlacement(bounds,
+ maximized ? ui::SHOW_STATE_MAXIMIZED :
+ ui::SHOW_STATE_NORMAL);
}
}
-bool BrowserView::GetSavedWindowPlacement(
- gfx::Rect* bounds,
- ui::WindowShowState* show_state) const {
+bool BrowserView::GetSavedWindowBounds(gfx::Rect* bounds) const {
*bounds = browser_->GetSavedWindowBounds();
- *show_state = browser_->GetSavedWindowShowState();
-
if (browser_->is_type_popup() || browser_->is_type_panel()) {
// We are a popup window. The value passed in |bounds| represents two
// pieces of information:
@@ -1685,6 +1688,13 @@ bool BrowserView::GetSavedWindowPlacement(
return true;
}
+bool BrowserView::GetSavedMaximizedState(bool* maximized) const {
+ // TODO(dhollowa): Add support for session restore of minimized state.
+ // http://crbug.com/43274
+ *maximized = browser_->GetSavedWindowShowState() == ui::SHOW_STATE_MAXIMIZED;
+ return true;
+}
+
views::View* BrowserView::GetContentsView() {
return contents_container_;
}
diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h
index bb660ad..9cf273c 100644
--- a/chrome/browser/ui/views/frame/browser_view.h
+++ b/chrome/browser/ui/views/frame/browser_view.h
@@ -394,10 +394,9 @@ class BrowserView : public BrowserBubbleHost,
virtual bool ExecuteWindowsCommand(int command_id) OVERRIDE;
virtual std::wstring GetWindowName() const OVERRIDE;
virtual void SaveWindowPlacement(const gfx::Rect& bounds,
- ui::WindowShowState show_state) OVERRIDE;
- virtual bool GetSavedWindowPlacement(
- gfx::Rect* bounds,
- ui::WindowShowState* show_state) const OVERRIDE;
+ bool maximized) OVERRIDE;
+ virtual bool GetSavedWindowBounds(gfx::Rect* bounds) const OVERRIDE;
+ virtual bool GetSavedMaximizedState(bool* maximized) const OVERRIDE;
virtual views::View* GetContentsView() OVERRIDE;
virtual views::ClientView* CreateClientView(views::Widget* widget) OVERRIDE;
virtual void OnWindowBeginUserBoundsChange() OVERRIDE;
diff --git a/chrome/browser/ui/views/menu_model_adapter_test.cc b/chrome/browser/ui/views/menu_model_adapter_test.cc
index 39a15da..a13e165 100644
--- a/chrome/browser/ui/views/menu_model_adapter_test.cc
+++ b/chrome/browser/ui/views/menu_model_adapter_test.cc
@@ -44,13 +44,16 @@ class TestViewsDelegate : public views::ViewsDelegate {
virtual void SaveWindowPlacement(const views::Widget* widget,
const std::wstring& window_name,
const gfx::Rect& bounds,
- ui::WindowShowState show_state) OVERRIDE {
+ bool maximized) OVERRIDE {
}
- virtual bool GetSavedWindowPlacement(
- const std::wstring& window_name,
- gfx::Rect* bounds,
- ui::WindowShowState* show_state) const OVERRIDE {
+ virtual bool GetSavedWindowBounds(const std::wstring& window_name,
+ gfx::Rect* bounds) const OVERRIDE {
+ return false;
+ }
+
+ virtual bool GetSavedMaximizedState(const std::wstring& window_name,
+ bool* maximized) const OVERRIDE {
return false;
}
diff --git a/ui/base/ui_base_types.h b/ui/base/ui_base_types.h
index 89a00a2..6a20bb5 100644
--- a/ui/base/ui_base_types.h
+++ b/ui/base/ui_base_types.h
@@ -16,8 +16,7 @@ enum WindowShowState {
SHOW_STATE_NORMAL = 1,
SHOW_STATE_MINIMIZED = 2,
SHOW_STATE_MAXIMIZED = 3,
- SHOW_STATE_INACTIVE = 4, // Views only, not persisted.
- SHOW_STATE_MAX = 5
+ SHOW_STATE_MAX = 4
};
} // namespace ui
diff --git a/views/desktop/desktop_views_delegate.cc b/views/desktop/desktop_views_delegate.cc
index b0f7ea2..6e64702 100644
--- a/views/desktop/desktop_views_delegate.cc
+++ b/views/desktop/desktop_views_delegate.cc
@@ -35,13 +35,17 @@ View* DesktopViewsDelegate::GetDefaultParentView() {
void DesktopViewsDelegate::SaveWindowPlacement(const Widget* widget,
const std::wstring& window_name,
const gfx::Rect& bounds,
- ui::WindowShowState show_state) {
+ bool maximized) {
}
-bool DesktopViewsDelegate::GetSavedWindowPlacement(
+bool DesktopViewsDelegate::GetSavedWindowBounds(const std::wstring& window_name,
+ gfx::Rect* bounds) const {
+ return false;
+}
+
+bool DesktopViewsDelegate::GetSavedMaximizedState(
const std::wstring& window_name,
- gfx::Rect* bounds,
- ui::WindowShowState* show_state) const {
+ bool* maximized) const {
return false;
}
diff --git a/views/desktop/desktop_views_delegate.h b/views/desktop/desktop_views_delegate.h
index 1704a97..145a29f 100644
--- a/views/desktop/desktop_views_delegate.h
+++ b/views/desktop/desktop_views_delegate.h
@@ -23,11 +23,11 @@ class DesktopViewsDelegate : public ViewsDelegate {
virtual void SaveWindowPlacement(const Widget* widget,
const std::wstring& window_name,
const gfx::Rect& bounds,
- ui::WindowShowState show_state) OVERRIDE;
- virtual bool GetSavedWindowPlacement(
- const std::wstring& window_name,
- gfx::Rect* bounds,
- ui::WindowShowState* show_state) const OVERRIDE;
+ bool maximized) OVERRIDE;
+ virtual bool GetSavedWindowBounds(const std::wstring& window_name,
+ gfx::Rect* bounds) const OVERRIDE;
+ virtual bool GetSavedMaximizedState(const std::wstring& window_name,
+ bool* maximized) const OVERRIDE;
virtual void NotifyAccessibilityEvent(
views::View* view, ui::AccessibilityTypes::Event event_type) OVERRIDE;
virtual void NotifyMenuItemFocused(
diff --git a/views/desktop/desktop_window_view.cc b/views/desktop/desktop_window_view.cc
index f3033b2..dcd8a6a 100644
--- a/views/desktop/desktop_window_view.cc
+++ b/views/desktop/desktop_window_view.cc
@@ -135,7 +135,7 @@ void DesktopWindowView::CreateDesktopWindow(DesktopType type) {
params.native_widget = new views::NativeWidgetWayland(window);
#elif defined(TOOLKIT_USES_GTK)
params.native_widget = new views::NativeWidgetGtk(window);
- params.show_state = ui::SHOW_STATE_MAXIMIZED;
+ params.maximize = true;
#endif
params.bounds = gfx::Rect(20, 20, 1920, 1200);
window->Init(params);
diff --git a/views/test/test_views_delegate.cc b/views/test/test_views_delegate.cc
index 7793dc4..d25e729 100644
--- a/views/test/test_views_delegate.cc
+++ b/views/test/test_views_delegate.cc
@@ -31,16 +31,13 @@ View* TestViewsDelegate::GetDefaultParentView() {
return default_parent_view_;
}
-void TestViewsDelegate::SaveWindowPlacement(const Widget* window,
- const std::wstring& window_name,
- const gfx::Rect& bounds,
- ui::WindowShowState show_state) {
+bool TestViewsDelegate::GetSavedWindowBounds(const std::wstring& window_name,
+ gfx::Rect* bounds) const {
+ return false;
}
-bool TestViewsDelegate::GetSavedWindowPlacement(
- const std::wstring& window_name,
- gfx::Rect* bounds,
- ui:: WindowShowState* show_state) const {
+bool TestViewsDelegate::GetSavedMaximizedState(const std::wstring& window_name,
+ bool* maximized) const {
return false;
}
diff --git a/views/test/test_views_delegate.h b/views/test/test_views_delegate.h
index 8d07bfc..82618ff 100644
--- a/views/test/test_views_delegate.h
+++ b/views/test/test_views_delegate.h
@@ -35,11 +35,12 @@ class TestViewsDelegate : public ViewsDelegate {
virtual void SaveWindowPlacement(const Widget* window,
const std::wstring& window_name,
const gfx::Rect& bounds,
- ui::WindowShowState show_state) OVERRIDE;
- virtual bool GetSavedWindowPlacement(
- const std::wstring& window_name,
- gfx::Rect* bounds,
- ui::WindowShowState* show_state) const OVERRIDE;
+ bool maximized) OVERRIDE {}
+ virtual bool GetSavedWindowBounds(const std::wstring& window_name,
+ gfx::Rect* bounds) const OVERRIDE;
+
+ virtual bool GetSavedMaximizedState(const std::wstring& window_name,
+ bool* maximized) const OVERRIDE;
virtual void NotifyAccessibilityEvent(
View* view, ui::AccessibilityTypes::Event event_type) OVERRIDE {}
diff --git a/views/views_delegate.h b/views/views_delegate.h
index 4b032c3..13baff0 100644
--- a/views/views_delegate.h
+++ b/views/views_delegate.h
@@ -12,7 +12,6 @@
#endif
#include "ui/base/accessibility/accessibility_types.h"
-#include "ui/base/ui_base_types.h"
#include "views/views_export.h"
namespace gfx {
@@ -47,19 +46,22 @@ class VIEWS_EXPORT ViewsDelegate {
// TODO(beng): perhaps this should be a Widget.
virtual View* GetDefaultParentView() = 0;
- // Saves the position, size and "show" state for the window with the
+ // Saves the position, size and maximized state for the window with the
// specified name.
virtual void SaveWindowPlacement(const Widget* widget,
const std::wstring& window_name,
const gfx::Rect& bounds,
- ui::WindowShowState show_state) = 0;
-
- // Retrieves the saved position and size and "show" state for the window with
- // the specified name.
- virtual bool GetSavedWindowPlacement(
- const std::wstring& window_name,
- gfx::Rect* bounds,
- ui::WindowShowState* show_state) const = 0;
+ bool maximized) = 0;
+
+ // Retrieves the saved position and size for the window with the specified
+ // name.
+ virtual bool GetSavedWindowBounds(const std::wstring& window_name,
+ gfx::Rect* bounds) const = 0;
+
+ // Retrieves the saved maximized state for the window with the specified
+ // name.
+ virtual bool GetSavedMaximizedState(const std::wstring& window_name,
+ bool* maximized) const = 0;
virtual void NotifyAccessibilityEvent(
views::View* view, ui::AccessibilityTypes::Event event_type) = 0;
diff --git a/views/widget/native_widget_gtk.cc b/views/widget/native_widget_gtk.cc
index 3db5d91..dd57b00 100644
--- a/views/widget/native_widget_gtk.cc
+++ b/views/widget/native_widget_gtk.cc
@@ -1004,9 +1004,8 @@ void NativeWidgetGtk::CenterWindow(const gfx::Size& size) {
SetBoundsConstrained(bounds, NULL);
}
-void NativeWidgetGtk::GetWindowPlacement(
- gfx::Rect* bounds,
- ui::WindowShowState* show_state) const {
+void NativeWidgetGtk::GetWindowBoundsAndMaximizedState(gfx::Rect* bounds,
+ bool* maximized) const {
// Do nothing for now. ChromeOS isn't yet saving window placement.
}
@@ -1187,9 +1186,9 @@ void NativeWidgetGtk::ShowMaximizedWithBounds(
Show();
}
-void NativeWidgetGtk::ShowWithWindowState(ui::WindowShowState show_state) {
+void NativeWidgetGtk::ShowWithState(ShowState state) {
// No concept of maximization (yet) on ChromeOS.
- if (show_state == ui::SHOW_STATE_INACTIVE)
+ if (state == internal::NativeWidgetPrivate::SHOW_INACTIVE)
gtk_window_set_focus_on_map(GetNativeWindow(), false);
gtk_widget_show(GetNativeView());
}
@@ -2077,14 +2076,10 @@ void NativeWidgetGtk::SaveWindowPosition() {
if (!GetWidget()->widget_delegate())
return;
- 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;
+ bool maximized = window_state_ & GDK_WINDOW_STATE_MAXIMIZED;
GetWidget()->widget_delegate()->SaveWindowPlacement(
GetWidget()->GetWindowScreenBounds(),
- show_state);
+ maximized);
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/views/widget/native_widget_gtk.h b/views/widget/native_widget_gtk.h
index 798d035..659db5f 100644
--- a/views/widget/native_widget_gtk.h
+++ b/views/widget/native_widget_gtk.h
@@ -166,9 +166,8 @@ 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 GetWindowPlacement(
- gfx::Rect* bounds,
- ui::WindowShowState* show_state) const OVERRIDE;
+ virtual void GetWindowBoundsAndMaximizedState(gfx::Rect* bounds,
+ bool* maximized) const OVERRIDE;
virtual void SetWindowTitle(const std::wstring& title) OVERRIDE;
virtual void SetWindowIcons(const SkBitmap& window_icon,
const SkBitmap& app_icon) OVERRIDE;
@@ -193,7 +192,7 @@ class VIEWS_EXPORT NativeWidgetGtk : public internal::NativeWidgetPrivate,
virtual void Hide() OVERRIDE;
virtual void ShowMaximizedWithBounds(
const gfx::Rect& restored_bounds) OVERRIDE;
- virtual void ShowWithWindowState(ui::WindowShowState window_state) OVERRIDE;
+ virtual void ShowWithState(ShowState 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 dbeab12..df332cf 100644
--- a/views/widget/native_widget_private.h
+++ b/views/widget/native_widget_private.h
@@ -137,11 +137,10 @@ 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 "show" state, for
+ // Retrieves the window's current restored bounds and maximized state, for
// persisting.
- virtual void GetWindowPlacement(
- gfx::Rect* bounds,
- ui::WindowShowState* show_state) const = 0;
+ virtual void GetWindowBoundsAndMaximizedState(gfx::Rect* bounds,
+ bool* maximized) const = 0;
// Sets the NativeWindow title.
virtual void SetWindowTitle(const std::wstring& title) = 0;
@@ -157,6 +156,12 @@ 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;
@@ -179,7 +184,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 ShowWithWindowState(ui::WindowShowState show_state) = 0;
+ virtual void ShowWithState(ShowState 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 017c80c..eb7047f 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::GetWindowPlacement(
+void NativeWidgetViews::GetWindowBoundsAndMaximizedState(
gfx::Rect* bounds,
- ui::WindowShowState* show_state) const {
+ bool* maximized) const {
*bounds = GetView()->bounds();
- *show_state = ui::SHOW_STATE_NORMAL;
+ *maximized = false;
}
void NativeWidgetViews::SetWindowTitle(const std::wstring& title) {
@@ -349,7 +349,7 @@ void NativeWidgetViews::Hide() {
ReleaseMouseCapture();
}
-void NativeWidgetViews::ShowWithWindowState(ui::WindowShowState show_state) {
+void NativeWidgetViews::ShowWithState(ShowState state) {
Show();
}
diff --git a/views/widget/native_widget_views.h b/views/widget/native_widget_views.h
index ceaccc4..2095d12 100644
--- a/views/widget/native_widget_views.h
+++ b/views/widget/native_widget_views.h
@@ -78,9 +78,8 @@ 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 GetWindowPlacement(
- gfx::Rect* bounds,
- ui::WindowShowState* show_state) const OVERRIDE;
+ virtual void GetWindowBoundsAndMaximizedState(gfx::Rect* bounds,
+ bool* maximized) const OVERRIDE;
virtual void SetWindowTitle(const std::wstring& title) OVERRIDE;
virtual void SetWindowIcons(const SkBitmap& window_icon,
const SkBitmap& app_icon) OVERRIDE;
@@ -105,7 +104,7 @@ class VIEWS_EXPORT NativeWidgetViews : public internal::NativeWidgetPrivate {
virtual void Hide() OVERRIDE;
virtual void ShowMaximizedWithBounds(
const gfx::Rect& restored_bounds) OVERRIDE;
- virtual void ShowWithWindowState(ui::WindowShowState window_state) OVERRIDE;
+ virtual void ShowWithState(ShowState 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 81fd9a3..2701173 100644
--- a/views/widget/native_widget_win.cc
+++ b/views/widget/native_widget_win.cc
@@ -637,12 +637,11 @@ void NativeWidgetWin::CenterWindow(const gfx::Size& size) {
ui::CenterAndSizeWindow(parent, GetNativeView(), size, false);
}
-void NativeWidgetWin::GetWindowPlacement(
- gfx::Rect* bounds,
- ui::WindowShowState* show_state) const {
+void NativeWidgetWin::GetWindowBoundsAndMaximizedState(gfx::Rect* bounds,
+ bool* maximized) const {
WINDOWPLACEMENT wp;
wp.length = sizeof(wp);
- const bool succeeded = !!::GetWindowPlacement(GetNativeView(), &wp);
+ const bool succeeded = !!GetWindowPlacement(GetNativeView(), &wp);
DCHECK(succeeded);
if (bounds != NULL) {
@@ -657,14 +656,8 @@ void NativeWidgetWin::GetWindowPlacement(
mi.rcWork.top - mi.rcMonitor.top);
}
- 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;
- }
+ if (maximized != NULL)
+ *maximized = (wp.showCmd == SW_SHOWMAXIMIZED);
}
void NativeWidgetWin::SetWindowTitle(const std::wstring& title) {
@@ -768,7 +761,7 @@ gfx::Rect NativeWidgetWin::GetRestoredBounds() const {
return gfx::Rect(saved_window_info_.window_rect);
gfx::Rect bounds;
- GetWindowPlacement(&bounds, NULL);
+ GetWindowBoundsAndMaximizedState(&bounds, NULL);
return bounds;
}
@@ -884,18 +877,15 @@ void NativeWidgetWin::ShowMaximizedWithBounds(
SetWindowPlacement(hwnd(), &placement);
}
-void NativeWidgetWin::ShowWithWindowState(ui::WindowShowState show_state) {
+void NativeWidgetWin::ShowWithState(ShowState state) {
DWORD native_show_state;
- switch (show_state) {
- case ui::SHOW_STATE_INACTIVE:
+ switch (state) {
+ case SHOW_INACTIVE:
native_show_state = SW_SHOWNOACTIVATE;
break;
- case ui::SHOW_STATE_MAXIMIZED:
+ case SHOW_MAXIMIZED:
native_show_state = SW_SHOWMAXIMIZED;
break;
- case ui::SHOW_STATE_MINIMIZED:
- native_show_state = SW_SHOWMINIMIZED;
- break;
default:
native_show_state = GetShowState();
break;
@@ -2186,10 +2176,8 @@ void NativeWidgetWin::SetInitParams(const Widget::InitParams& params) {
// Set type-independent style attributes.
if (params.child)
style |= WS_CHILD | WS_VISIBLE;
- if (params.show_state == ui::SHOW_STATE_MAXIMIZED)
+ if (params.maximize)
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 3cfa9c6..c29d354 100644
--- a/views/widget/native_widget_win.h
+++ b/views/widget/native_widget_win.h
@@ -209,9 +209,8 @@ 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 GetWindowPlacement(
- gfx::Rect* bounds,
- ui::WindowShowState* show_state) const OVERRIDE;
+ virtual void GetWindowBoundsAndMaximizedState(gfx::Rect* bounds,
+ bool* maximized) const OVERRIDE;
virtual void SetWindowTitle(const std::wstring& title) OVERRIDE;
virtual void SetWindowIcons(const SkBitmap& window_icon,
const SkBitmap& app_icon) OVERRIDE;
@@ -236,7 +235,7 @@ class VIEWS_EXPORT NativeWidgetWin : public ui::WindowImpl,
virtual void Hide() OVERRIDE;
virtual void ShowMaximizedWithBounds(
const gfx::Rect& restored_bounds) OVERRIDE;
- virtual void ShowWithWindowState(ui::WindowShowState show_state) OVERRIDE;
+ virtual void ShowWithState(ShowState 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 534efc1..80ca73d 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),
- show_state(ui::SHOW_STATE_DEFAULT),
+ maximize(false),
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),
- show_state(ui::SHOW_STATE_DEFAULT),
+ maximize(false),
double_buffer(false),
parent(NULL),
parent_widget(NULL),
@@ -158,11 +158,10 @@ Widget::Widget()
frame_type_(FRAME_TYPE_DEFAULT),
disable_inactive_rendering_(false),
widget_closed_(false),
- saved_show_state_(ui::SHOW_STATE_DEFAULT),
+ saved_maximized_state_(false),
minimum_size_(100, 100),
focus_on_creation_(true),
- is_top_level_(false),
- native_widget_created_(false) {
+ is_top_level_(false) {
}
Widget::~Widget() {
@@ -312,10 +311,8 @@ 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.show_state == ui::SHOW_STATE_MAXIMIZED)
+ if (params.maximize)
Maximize();
- else if (params.show_state == ui::SHOW_STATE_MINIMIZED)
- Minimize();
UpdateWindowTitle();
}
}
@@ -449,7 +446,7 @@ void Widget::Close() {
if (non_client_view_)
can_close = non_client_view_->CanClose();
if (can_close) {
- SaveWindowPlacement();
+ SaveWindowPosition();
// During tear-down the top-level focus manager becomes unavailable to
// GTK tabbed panes and their children, so normal deregistration via
@@ -476,16 +473,17 @@ void Widget::EnableClose(bool enable) {
void Widget::Show() {
if (non_client_view_) {
- if (saved_show_state_ == ui::SHOW_STATE_MAXIMIZED &&
- !initial_restored_bounds_.IsEmpty()) {
+ if (saved_maximized_state_ && !initial_restored_bounds_.IsEmpty()) {
native_widget_->ShowMaximizedWithBounds(initial_restored_bounds_);
} else {
- native_widget_->ShowWithWindowState(saved_show_state_);
+ native_widget_->ShowWithState(saved_maximized_state_ ?
+ internal::NativeWidgetPrivate::SHOW_MAXIMIZED :
+ internal::NativeWidgetPrivate::SHOW_RESTORED);
}
- // |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
+ // |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
// it is subsequently shown after being hidden.
- saved_show_state_ = ui::SHOW_STATE_NORMAL;
+ saved_maximized_state_ = false;
} else {
native_widget_->Show();
}
@@ -496,16 +494,14 @@ void Widget::Hide() {
}
void Widget::ShowInactive() {
- // 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()) {
+ // 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()) {
SetBounds(initial_restored_bounds_);
- saved_show_state_ = ui::SHOW_STATE_NORMAL;
+ saved_maximized_state_ = false;
}
- native_widget_->ShowWithWindowState(ui::SHOW_STATE_INACTIVE);
+ native_widget_->ShowWithState(internal::NativeWidgetPrivate::SHOW_INACTIVE);
}
void Widget::Activate() {
@@ -829,7 +825,7 @@ void Widget::EnableInactiveRendering() {
void Widget::OnNativeWidgetActivationChanged(bool active) {
if (!active) {
- SaveWindowPlacement();
+ SaveWindowPosition();
// Close any open menus.
MenuController* menu_controller = MenuController::GetActiveInstance();
@@ -870,8 +866,6 @@ void Widget::OnNativeWidgetCreated() {
if (widget_delegate_->IsModal())
native_widget_->BecomeModal();
-
- native_widget_created_ = true;
}
void Widget::OnNativeWidgetDestroying() {
@@ -892,12 +886,6 @@ 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_created_)
- SaveWindowPlacement();
}
void Widget::OnNativeWidgetBeginUserBoundsChange() {
@@ -1067,7 +1055,7 @@ bool Widget::ShouldReleaseCaptureOnMouseReleased() const {
return true;
}
-void Widget::SaveWindowPlacement() {
+void Widget::SaveWindowPosition() {
// 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
@@ -1075,10 +1063,10 @@ void Widget::SaveWindowPlacement() {
if (!widget_delegate_)
return;
- ui::WindowShowState show_state = ui::SHOW_STATE_NORMAL;
+ bool maximized = false;
gfx::Rect bounds;
- native_widget_->GetWindowPlacement(&bounds, &show_state);
- widget_delegate_->SaveWindowPlacement(bounds, show_state);
+ native_widget_->GetWindowBoundsAndMaximizedState(&bounds, &maximized);
+ widget_delegate_->SaveWindowPlacement(bounds, maximized);
}
void Widget::SetInitialBounds(const gfx::Rect& bounds) {
@@ -1086,8 +1074,8 @@ void Widget::SetInitialBounds(const gfx::Rect& bounds) {
return;
gfx::Rect saved_bounds;
- if (GetSavedWindowPlacement(&saved_bounds, &saved_show_state_)) {
- if (saved_show_state_ == ui::SHOW_STATE_MAXIMIZED) {
+ if (GetSavedBounds(&saved_bounds, &saved_maximized_state_)) {
+ if (saved_maximized_state_) {
// 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;
@@ -1106,17 +1094,17 @@ void Widget::SetInitialBounds(const gfx::Rect& bounds) {
}
}
-bool Widget::GetSavedWindowPlacement(gfx::Rect* bounds,
- ui::WindowShowState* show_state) {
+bool Widget::GetSavedBounds(gfx::Rect* bounds, bool* maximize) {
// 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_->GetSavedWindowPlacement(bounds, show_state)) {
+ if (widget_delegate_->GetSavedWindowBounds(bounds)) {
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 1c6e820..a85b619 100644
--- a/views/widget/widget.h
+++ b/views/widget/widget.h
@@ -12,7 +12,6 @@
#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"
@@ -145,8 +144,8 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate,
Ownership ownership;
bool mirror_origin_in_rtl;
bool has_dropshadow;
- // Whether the widget should be maximized or minimized.
- ui::WindowShowState show_state;
+ // Whether the widget should be maximized.
+ bool maximize;
// Should the widget be double buffered? Default is false.
bool double_buffer;
gfx::NativeView parent;
@@ -636,17 +635,16 @@ 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 "show" state using the
+ // Persists the window's restored position and maximized state using the
// window delegate.
- void SaveWindowPlacement();
+ void SaveWindowPosition();
// Sizes and positions the window just after it is created.
void SetInitialBounds(const gfx::Rect& bounds);
- // Returns the bounds and "show" state from the delegate. Returns true if
+ // Returns the bounds and maximized state from the delegate. Returns true if
// the delegate wants to use a specified bounds.
- bool GetSavedWindowPlacement(gfx::Rect* bounds,
- ui::WindowShowState* show_state);
+ bool GetSavedBounds(gfx::Rect* bounds, bool* maximize);
// Sets a different InputMethod instance to this widget. The instance
// must not be initialized, the ownership will be assumed by the widget.
@@ -705,12 +703,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 "show" state for this window. See note in SetInitialBounds
+ // The saved maximized state for this window. See note in SetInitialBounds
// that explains why we save this.
- ui::WindowShowState saved_show_state_;
+ bool saved_maximized_state_;
// The restored bounds used for the initial show. This is only used if
- // |saved_show_state_| is maximized.
+ // |saved_maximized_state_| is true.
gfx::Rect initial_restored_bounds_;
// The smallest size the window can be.
@@ -729,9 +727,6 @@ 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 created.
- bool native_widget_created_;
-
DISALLOW_COPY_AND_ASSIGN(Widget);
};
diff --git a/views/widget/widget_delegate.cc b/views/widget/widget_delegate.cc
index 25cb54a..d031295 100644
--- a/views/widget/widget_delegate.cc
+++ b/views/widget/widget_delegate.cc
@@ -98,24 +98,31 @@ std::wstring WidgetDelegate::GetWindowName() const {
}
void WidgetDelegate::SaveWindowPlacement(const gfx::Rect& bounds,
- ui::WindowShowState show_state) {
+ bool maximized) {
std::wstring window_name = GetWindowName();
if (!ViewsDelegate::views_delegate || window_name.empty())
return;
ViewsDelegate::views_delegate->SaveWindowPlacement(
- GetWidget(), window_name, bounds, show_state);
+ GetWidget(), window_name, bounds, maximized);
}
-bool WidgetDelegate::GetSavedWindowPlacement(
- gfx::Rect* bounds,
- ui::WindowShowState* show_state) const {
+bool WidgetDelegate::GetSavedWindowBounds(gfx::Rect* bounds) const {
std::wstring window_name = GetWindowName();
if (!ViewsDelegate::views_delegate || window_name.empty())
return false;
- return ViewsDelegate::views_delegate->GetSavedWindowPlacement(
- window_name, bounds, show_state);
+ 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);
}
bool WidgetDelegate::ShouldRestoreWindowSize() const {
diff --git a/views/widget/widget_delegate.h b/views/widget/widget_delegate.h
index 5c73d4d..85485e6 100644
--- a/views/widget/widget_delegate.h
+++ b/views/widget/widget_delegate.h
@@ -10,7 +10,6 @@
#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;
@@ -98,16 +97,15 @@ class VIEWS_EXPORT WidgetDelegate {
// state restoration.
virtual std::wstring GetWindowName() const;
- // Saves the window's bounds and "show" state. By default this uses the
+ // Saves the window's bounds and maximized states. 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,
- ui::WindowShowState show_state);
+ virtual void SaveWindowPlacement(const gfx::Rect& bounds, bool maximized);
- // Retrieves the window's bounds and "show" states.
+ // Retrieves the window's bounds and maximized states.
// This behavior can be overridden to provide additional functionality.
- virtual bool GetSavedWindowPlacement(gfx::Rect* bounds,
- ui::WindowShowState* show_state) const;
+ virtual bool GetSavedWindowBounds(gfx::Rect* bounds) const;
+ virtual bool GetSavedMaximizedState(bool* maximized) 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