summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorskuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-07 14:48:06 +0000
committerskuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-07 14:48:06 +0000
commit00681f080a462a62eb38f04faf0b73045e8878f6 (patch)
tree7c2215e80159ede1fa72092e107c7e1b8284ca26
parent50415647e4aad9b9cf4ea2112dcbe4cb9af02ac3 (diff)
downloadchromium_src-00681f080a462a62eb38f04faf0b73045e8878f6.zip
chromium_src-00681f080a462a62eb38f04faf0b73045e8878f6.tar.gz
chromium_src-00681f080a462a62eb38f04faf0b73045e8878f6.tar.bz2
Fixing an empty restore rectangle for V2 apps as well as leaving full screen when returning from maximize mode
BUG=369868 TEST=ash_unittests and visual Review URL: https://codereview.chromium.org/264133002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@268757 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/wm/default_state.cc6
-rw-r--r--ash/wm/maximize_mode/maximize_mode_window_manager_unittest.cc74
-rw-r--r--ash/wm/maximize_mode/maximize_mode_window_state.cc18
3 files changed, 87 insertions, 11 deletions
diff --git a/ash/wm/default_state.cc b/ash/wm/default_state.cc
index a26e78c..ada7e36 100644
--- a/ash/wm/default_state.cc
+++ b/ash/wm/default_state.cc
@@ -459,6 +459,12 @@ void DefaultState::ReenterToCurrentState(
WindowState* window_state,
WindowState::State* state_in_previous_mode) {
WindowStateType previous_state_type = state_in_previous_mode->GetType();
+ if (previous_state_type == wm::WINDOW_STATE_TYPE_FULLSCREEN) {
+ // A state change should not move a window out of full screen since full
+ // screen is a "special mode" the user wanted to be in and should be
+ // respected as such.
+ state_type_ = wm::WINDOW_STATE_TYPE_FULLSCREEN;
+ }
window_state->UpdateWindowShowStateFromStateType();
window_state->NotifyPreStateTypeChange(previous_state_type);
diff --git a/ash/wm/maximize_mode/maximize_mode_window_manager_unittest.cc b/ash/wm/maximize_mode/maximize_mode_window_manager_unittest.cc
index b95aef6..6b1c244 100644
--- a/ash/wm/maximize_mode/maximize_mode_window_manager_unittest.cc
+++ b/ash/wm/maximize_mode/maximize_mode_window_manager_unittest.cc
@@ -798,7 +798,8 @@ TEST_F(MaximizeModeWindowManagerTest, KeepFullScreenModeOn) {
EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state());
}
-// Check that full screen mode can be turned on in maximized mode.
+// Check that full screen mode can be turned on in maximized mode and remains
+// upon coming back.
TEST_F(MaximizeModeWindowManagerTest, AllowFullScreenMode) {
gfx::Rect rect(20, 140, 100, 100);
scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
@@ -828,11 +829,76 @@ TEST_F(MaximizeModeWindowManagerTest, AllowFullScreenMode) {
EXPECT_FALSE(window_state->IsMaximized());
EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state());
- // With the destruction of the manager we should fall back to the old state.
+ // With the destruction of the manager we should remain in full screen.
DestroyMaximizeModeWindowManager();
- EXPECT_FALSE(window_state->IsFullscreen());
+ EXPECT_TRUE(window_state->IsFullscreen());
EXPECT_FALSE(window_state->IsMaximized());
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state());
+}
+
+// Check that the full screen mode will stay active when the maximize mode is
+// ended.
+TEST_F(MaximizeModeWindowManagerTest,
+ FullScreenModeRemainsWhenCreatedInMaximizedMode) {
+ CreateMaximizeModeWindowManager();
+
+ gfx::Rect rect(20, 140, 100, 100);
+ scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
+ wm::WindowState* window_state = wm::GetWindowState(w1.get());
+ wm::WMEvent event_full_screen(wm::WM_EVENT_TOGGLE_FULLSCREEN);
+ window_state->OnWMEvent(&event_full_screen);
+ EXPECT_TRUE(window_state->IsFullscreen());
+
+ // After the maximize mode manager is ended, full screen will remain.
+ DestroyMaximizeModeWindowManager();
+ EXPECT_TRUE(window_state->IsFullscreen());
+}
+
+// Check that the full screen mode will stay active throughout a maximzied mode
+// session.
+TEST_F(MaximizeModeWindowManagerTest,
+ FullScreenModeRemainsThroughMaximizeModeSwitch) {
+ gfx::Rect rect(20, 140, 100, 100);
+ scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
+ wm::WindowState* window_state = wm::GetWindowState(w1.get());
+ wm::WMEvent event_full_screen(wm::WM_EVENT_TOGGLE_FULLSCREEN);
+ window_state->OnWMEvent(&event_full_screen);
+ EXPECT_TRUE(window_state->IsFullscreen());
+
+ CreateMaximizeModeWindowManager();
+ EXPECT_TRUE(window_state->IsFullscreen());
+ DestroyMaximizeModeWindowManager();
+ EXPECT_TRUE(window_state->IsFullscreen());
+}
+
+// Check that an empty window does not get restored to a tiny size.
+TEST_F(MaximizeModeWindowManagerTest,
+ CreateAndMaximizeInMaximizeModeShouldRetoreToGoodSizeGoingToDefault) {
+ CreateMaximizeModeWindowManager();
+ gfx::Rect rect;
+ scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
+ w1->Show();
+ wm::WindowState* window_state = wm::GetWindowState(w1.get());
+ EXPECT_TRUE(window_state->IsMaximized());
+
+ // There is a calling order in which the restore bounds can get set to an
+ // empty rectangle. We simulate this here.
+ window_state->SetRestoreBoundsInScreen(rect);
+ EXPECT_TRUE(window_state->GetRestoreBoundsInScreen().IsEmpty());
+
+ // Setting the window to a new size will physically not change the window,
+ // but the restore size should get updated so that a restore later on will
+ // return to this size.
+ gfx::Rect requested_bounds(10, 20, 50, 70);
+ w1->SetBounds(requested_bounds);
+ EXPECT_TRUE(window_state->IsMaximized());
+ EXPECT_EQ(requested_bounds.ToString(),
+ window_state->GetRestoreBoundsInScreen().ToString());
+
+ DestroyMaximizeModeWindowManager();
+
+ EXPECT_FALSE(window_state->IsMaximized());
+ EXPECT_EQ(w1->bounds().ToString(), requested_bounds.ToString());
}
// Check that snapping operations get ignored.
diff --git a/ash/wm/maximize_mode/maximize_mode_window_state.cc b/ash/wm/maximize_mode/maximize_mode_window_state.cc
index 57505ee..5c6623b 100644
--- a/ash/wm/maximize_mode/maximize_mode_window_state.cc
+++ b/ash/wm/maximize_mode/maximize_mode_window_state.cc
@@ -142,13 +142,17 @@ void MaximizeModeWindowState::OnWMEvent(wm::WindowState* window_state,
case wm::WM_EVENT_SHOW_INACTIVE:
return;
case wm::WM_EVENT_SET_BOUNDS:
- if (window_state->CanResize()) {
- // In case the window is resizable and / or maximized we ignore the
- // requested bounds change and resize to the biggest possible size.
- UpdateBounds(window_state, true);
- } else
- if (current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED &&
- current_state_type_ != wm::WINDOW_STATE_TYPE_MAXIMIZED) {
+ if (current_state_type_ == wm::WINDOW_STATE_TYPE_MAXIMIZED) {
+ // Having a maximized window, it could have been created with an empty
+ // size and the caller should get his size upon leaving the maximized
+ // mode. As such we set the restore bounds to the requested bounds.
+ gfx::Rect bounds_in_parent =
+ (static_cast<const wm::SetBoundsEvent*>(event))->requested_bounds();
+ if (!bounds_in_parent.IsEmpty())
+ window_state->SetRestoreBoundsInParent(bounds_in_parent);
+ } else if (current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED &&
+ current_state_type_ != wm::WINDOW_STATE_TYPE_MAXIMIZED &&
+ current_state_type_ != wm::WINDOW_STATE_TYPE_FULLSCREEN) {
// In all other cases (except for minimized windows) we respect the
// requested bounds and center it to a fully visible area on the screen.
gfx::Rect bounds_in_parent =