Commit 35afaeb4 authored by flackr's avatar flackr Committed by Commit bot

Don't minimize dragged window when shelf hidden.

If the shelf hides we should not immediately minimize a dragged panel. This panel can be dropped where it now is and detached.

BUG=393047
TEST=PanelWindowResizerTest.DetachThenHideShelf
TEST=Drag a panel window while switching profiles. There is no crash and the window is detached where it was when switching back.

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

Cr-Commit-Position: refs/heads/master@{#295711}
parent 4bf6b514
......@@ -551,10 +551,14 @@ void PanelLayoutManager::WillChangeVisibilityState(
return;
scoped_ptr<aura::WindowTracker> minimized_windows(new aura::WindowTracker);
for (PanelList::iterator iter = panel_windows_.begin();
iter != panel_windows_.end(); ++iter) {
if (iter->window->IsVisible()) {
minimized_windows->Add(iter->window);
wm::GetWindowState(iter->window)->Minimize();
iter != panel_windows_.end();) {
aura::Window* window = iter->window;
// Minimizing a panel window may remove it from the panel_windows_ list.
// Advance the iterator before minimizing it: http://crbug.com/393047.
++iter;
if (window != dragged_panel_ && window->IsVisible()) {
minimized_windows->Add(window);
wm::GetWindowState(window)->Minimize();
}
}
restore_windows_on_shelf_visible_ = minimized_windows.Pass();
......
......@@ -273,6 +273,38 @@ TEST_F(PanelWindowResizerTest, PanelDetachReattachTop) {
DetachReattachTest(window.get(), 0, 1);
}
// Tests that a drag continues when the shelf is hidden. This occurs as part of
// the animation when switching profiles. http://crbug.com/393047.
TEST_F(PanelWindowResizerTest, DetachThenHideShelf) {
if (!SupportsHostWindowResize())
return;
scoped_ptr<aura::Window> window(
CreatePanelWindow(gfx::Point(0, 0)));
wm::WindowState* state = wm::GetWindowState(window.get());
gfx::Rect expected_bounds = window->GetBoundsInScreen();
expected_bounds.set_y(expected_bounds.y() - 100);
DragStart(window.get());
DragMove(0, -100);
EXPECT_FALSE(state->IsMinimized());
// Hide the shelf. This minimizes all attached windows but should ignore
// the dragged window.
ShelfLayoutManager* shelf = RootWindowController::ForWindow(window.get())->
shelf()->shelf_layout_manager();
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN);
shelf->UpdateVisibilityState();
RunAllPendingInMessageLoop();
EXPECT_FALSE(state->IsMinimized());
EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id());
DragEnd();
// When the drag ends the window should be detached and placed where it was
// dragged to.
EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
EXPECT_FALSE(state->IsMinimized());
EXPECT_EQ(expected_bounds.ToString(), window->GetBoundsInScreen().ToString());
}
TEST_F(PanelWindowResizerTest, PanelDetachReattachMultipleDisplays) {
if (!SupportsMultipleDisplays())
return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment