Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Unified Diff: ui/views/widget/widget.cc

Issue 1489843003: [WIP: Not for review] Simplify and unify widget/window show logic Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/widget/widget.cc
diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc
index 6873cdef533fd482cec2b6a5d2a34a1692fb5bcb..a03ba7ba655269a203168184f27f2b2095be95d1 100644
--- a/ui/views/widget/widget.cc
+++ b/ui/views/widget/widget.cc
@@ -631,15 +631,12 @@ void Widget::Show() {
// While initializing, the kiosk mode will go to full screen before the
// widget gets shown. In that case we stay in full screen mode, regardless
// of the |saved_show_state_| member.
- if (saved_show_state_ == ui::SHOW_STATE_MAXIMIZED &&
- !initial_restored_bounds_.IsEmpty() &&
- !IsFullscreen()) {
+ if (((saved_show_state_ == ui::SHOW_STATE_MAXIMIZED && !IsFullscreen()) ||
+ IsMaximized()) &&
+ !initial_restored_bounds_.IsEmpty()) {
native_widget_->ShowMaximizedWithBounds(initial_restored_bounds_);
} else {
- ui::WindowShowState show_state =
- IsFullscreen() ? ui::SHOW_STATE_FULLSCREEN :
- IsMinimized() ? ui::SHOW_STATE_MINIMIZED : saved_show_state_;
- native_widget_->ShowWithWindowState(show_state);
+ ShowWithCurrentState();
}
// |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
@@ -647,7 +644,7 @@ void Widget::Show() {
saved_show_state_ = ui::SHOW_STATE_NORMAL;
} else {
CanActivate()
- ? native_widget_->Show()
+ ? ShowWithCurrentState()
oshima 2015/12/01 23:00:06 This is necessary to honor show_state in the widge
: native_widget_->ShowWithWindowState(ui::SHOW_STATE_INACTIVE);
}
}
@@ -1453,6 +1450,8 @@ void Widget::SetInitialBounds(const gfx::Rect& bounds) {
native_widget_->CenterWindow(non_client_view_->GetPreferredSize());
} else {
// Use the supplied initial bounds.
+ if (IsMaximized())
+ initial_restored_bounds_ = bounds;
SetBoundsConstrained(bounds);
}
}
@@ -1500,6 +1499,16 @@ bool Widget::GetSavedWindowPlacement(gfx::Rect* bounds,
return false;
}
+void Widget::ShowWithCurrentState() {
+ ui::WindowShowState show_state =
+ IsFullscreen()
+ ? ui::SHOW_STATE_FULLSCREEN
+ : (IsMaximized() ? ui::SHOW_STATE_MAXIMIZED
+ : (IsMinimized() ? ui::SHOW_STATE_MINIMIZED
+ : saved_show_state_));
+ native_widget_->ShowWithWindowState(show_state);
+}
+
namespace internal {
////////////////////////////////////////////////////////////////////////////////

Powered by Google App Engine
This is Rietveld 408576698