Skip to content

Commit

Permalink
Fixing minimize problem with maximized mode.
Browse files Browse the repository at this point in the history
BUG=35989
TEST=unit test, visual verification

Review URL: https://codereview.chromium.org/227843005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262436 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
skuhne@chromium.org committed Apr 8, 2014
1 parent a162f72 commit b5618fe
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
28 changes: 28 additions & 0 deletions ash/wm/maximize_mode/maximize_mode_window_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,34 @@ TEST_F(MaximizeModeWindowManagerTest, IgnoreRestoreStateChages) {
DestroyMaximizeModeWindowManager();
}

// Check that minimize and restore do the right thing.
TEST_F(MaximizeModeWindowManagerTest, TestMinimize) {
gfx::Rect rect(10, 10, 100, 100);
scoped_ptr<aura::Window> window(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL,
rect));
wm::WindowState* window_state = wm::GetWindowState(window.get());
EXPECT_EQ(rect.ToString(), window->bounds().ToString());
ash::Shell::GetInstance()->EnableMaximizeModeWindowManager(true);
EXPECT_TRUE(window_state->IsMaximized());
EXPECT_FALSE(window_state->IsMinimized());
EXPECT_TRUE(window->IsVisible());

window_state->Minimize();
EXPECT_FALSE(window_state->IsMaximized());
EXPECT_TRUE(window_state->IsMinimized());
EXPECT_FALSE(window->IsVisible());

window_state->Maximize();
EXPECT_TRUE(window_state->IsMaximized());
EXPECT_FALSE(window_state->IsMinimized());
EXPECT_TRUE(window->IsVisible());

ash::Shell::GetInstance()->EnableMaximizeModeWindowManager(false);
EXPECT_FALSE(window_state->IsMaximized());
EXPECT_FALSE(window_state->IsMinimized());
EXPECT_TRUE(window->IsVisible());
}

// Check that a full screen window is changing to maximized in maximize mode,
// cannot go to fullscreen and goes back to fullscreen thereafter.
TEST_F(MaximizeModeWindowManagerTest, FullScreenModeTests) {
Expand Down
13 changes: 12 additions & 1 deletion ash/wm/maximize_mode/maximize_mode_window_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void MaximizeModeWindowState::OnWMEvent(wm::WindowState* window_state,
case wm::WM_EVENT_MINIMIZE:
if (current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED) {
current_state_type_ = wm::WINDOW_STATE_TYPE_MINIMIZED;
window_state->Minimize();
Minimize(window_state);
}
return;
case wm::WM_EVENT_SHOW_INACTIVE:
Expand Down Expand Up @@ -222,4 +222,15 @@ void MaximizeModeWindowState::MaximizeOrCenterWindow(
}
}

void MaximizeModeWindowState::Minimize(wm::WindowState* window_state) {
::wm::SetWindowVisibilityAnimationType(
window_state->window(), WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE);

// Hide the window.
window_state->window()->Hide();
// Activate another window.
if (window_state->IsActive())
window_state->Deactivate();
}

} // namespace ash
3 changes: 3 additions & 0 deletions ash/wm/maximize_mode/maximize_mode_window_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ class MaximizeModeWindowState : public wm::WindowState::State {
// set to true, a bounds change will be animated - otherwise immediate.
void MaximizeOrCenterWindow(wm::WindowState* window_state, bool animate);

// Minimize the window.
void Minimize(wm::WindowState* window_state);

// The original state object of the window.
scoped_ptr<wm::WindowState::State> old_state_;

Expand Down

0 comments on commit b5618fe

Please sign in to comment.