summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authortdanderson <tdanderson@chromium.org>2015-10-21 10:17:15 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-21 17:18:42 +0000
commitd24411e4b040ba26071cfccc95987488fb5420af (patch)
tree53e4960d8e0e65c92fe052e3f2a7795541b439ed /ash
parentfc199ea30c9558abb49215948fd6aa3936764c7c (diff)
downloadchromium_src-d24411e4b040ba26071cfccc95987488fb5420af.zip
chromium_src-d24411e4b040ba26071cfccc95987488fb5420af.tar.gz
chromium_src-d24411e4b040ba26071cfccc95987488fb5420af.tar.bz2
Do not re-enter fullscreen when switching Ash window states
If a window was in fullscreen prior to attaching a window state and then taken out of fullscreen while in that state, do not restore the window to fullscreen when the original window state is restored. BUG=529998,530000 TEST=MaximizeModeWindowManagerTest.KeepFullScreenModeOn, MaximizeModeWindowManagerTest.MinimizePreservedAfterLeavingFullscreen Review URL: https://codereview.chromium.org/1379723004 Cr-Commit-Position: refs/heads/master@{#355319}
Diffstat (limited to 'ash')
-rw-r--r--ash/wm/default_state.cc13
-rw-r--r--ash/wm/maximize_mode/maximize_mode_window_manager_unittest.cc44
2 files changed, 45 insertions, 12 deletions
diff --git a/ash/wm/default_state.cc b/ash/wm/default_state.cc
index 380ccaf..bacf035 100644
--- a/ash/wm/default_state.cc
+++ b/ash/wm/default_state.cc
@@ -584,12 +584,15 @@ 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.
+
+ // A state change should not move a window into or out of full screen since
+ // full screen is a "special mode" the user wanted to be in and should be
+ // respected as such.
+ if (previous_state_type == wm::WINDOW_STATE_TYPE_FULLSCREEN)
state_type_ = wm::WINDOW_STATE_TYPE_FULLSCREEN;
- }
+ else if (state_type_ == wm::WINDOW_STATE_TYPE_FULLSCREEN)
+ state_type_ = previous_state_type;
+
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 274956e..78d2933 100644
--- a/ash/wm/maximize_mode/maximize_mode_window_manager_unittest.cc
+++ b/ash/wm/maximize_mode/maximize_mode_window_manager_unittest.cc
@@ -830,8 +830,9 @@ TEST_F(MaximizeModeWindowManagerTest, TestMinimize) {
EXPECT_TRUE(window->IsVisible());
}
-// Check that a full screen window is staying full screen in maximize mode,
-// and that it returns to full screen thereafter (if left).
+// Check that a full screen window remains full screen upon entering maximize
+// mode. Furthermore, checks that this window is not full screen upon exiting
+// maximize mode if it was un-full-screened while in maximize mode.
TEST_F(MaximizeModeWindowManagerTest, KeepFullScreenModeOn) {
gfx::Rect rect(20, 140, 100, 100);
scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
@@ -865,12 +866,41 @@ TEST_F(MaximizeModeWindowManagerTest, KeepFullScreenModeOn) {
EXPECT_TRUE(window_state->IsMaximized());
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- // Ending the maximize mode should return to full screen and the shelf should
- // be hidden again.
+ // We left fullscreen mode while in maximize mode, so the window should
+ // remain maximized and the shelf should not change state upon exiting
+ // maximize mode.
DestroyMaximizeModeWindowManager();
- EXPECT_TRUE(window_state->IsFullscreen());
- EXPECT_FALSE(window_state->IsMaximized());
- EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state());
+ EXPECT_FALSE(window_state->IsFullscreen());
+ EXPECT_TRUE(window_state->IsMaximized());
+ EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
+}
+
+// Verifies that if a window is un-full-screened while in maximize mode,
+// other changes to that window's state (such as minimizing it) are
+// preserved upon exiting maximize mode.
+TEST_F(MaximizeModeWindowManagerTest, MinimizePreservedAfterLeavingFullscreen) {
+ 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());
+
+ ShelfLayoutManager* shelf =
+ Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager();
+
+ // Allow the shelf to hide and enter full screen.
+ shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
+ window_state->OnWMEvent(&event);
+ ASSERT_FALSE(window_state->IsMinimized());
+
+ // Enter maximize mode, exit full screen, and then minimize the window.
+ CreateMaximizeModeWindowManager();
+ window_state->OnWMEvent(&event);
+ window_state->Minimize();
+ ASSERT_TRUE(window_state->IsMinimized());
+
+ // The window should remain minimized when exiting maximize mode.
+ DestroyMaximizeModeWindowManager();
+ EXPECT_TRUE(window_state->IsMinimized());
}
// Check that full screen mode can be turned on in maximized mode and remains