Commit 531cf0b2 authored by varkha@chromium.org's avatar varkha@chromium.org

Do not show auto-hidden shelf when dragging a window

BUG=292238
TEST=ash_unittests --gtest_filter=*ShelfLayoutManagerTest*

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243964 0039d316-1c4b-4281-b951-d872f2087c98
parent 44bd4ba5
......@@ -10,6 +10,7 @@
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/wm/window_cycle_list.h"
#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace_controller.h"
#include "ui/aura/client/activation_client.h"
......@@ -31,6 +32,19 @@ void AddTrackedWindows(aura::Window* root,
windows->insert(windows->end(), children.begin(), children.end());
}
// Adds windows being dragged in the docked container to |windows| list.
void AddDraggedWindows(aura::Window* root,
MruWindowTracker::WindowList* windows) {
aura::Window* container = Shell::GetContainer(
root, internal::kShellWindowId_DockedContainer);
const MruWindowTracker::WindowList& children = container->children();
for (MruWindowTracker::WindowList::const_iterator iter = children.begin();
iter != children.end(); ++iter) {
if (wm::GetWindowState(*iter)->is_dragged())
windows->insert(windows->end(), *iter);
}
}
// Returns true if |window| is a container whose windows can be cycled to.
bool IsSwitchableContainer(aura::Window* window) {
if (!window)
......@@ -73,6 +87,10 @@ MruWindowTracker::WindowList BuildWindowListInternal(
for (size_t i = 0; i < kSwitchableWindowContainerIdsLength; ++i)
AddTrackedWindows(active_root, kSwitchableWindowContainerIds[i], &windows);
// Dragged windows are temporarily parented in docked container. Include them
// in the in tracked list.
AddDraggedWindows(active_root, &windows);
// Removes unfocusable windows.
MruWindowTracker::WindowList::iterator last =
std::remove_if(
......
......@@ -1282,7 +1282,7 @@ TEST_P(WorkspaceControllerTestDragging, DragWindowOverlapShelf) {
ShelfLayoutManager* shelf = shelf_layout_manager();
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
// Drag near the shelf
// Drag near the shelf.
aura::test::EventGenerator generator(
Shell::GetPrimaryRootWindow(), gfx::Point());
generator.MoveMouseTo(10, 10);
......@@ -1300,6 +1300,32 @@ TEST_P(WorkspaceControllerTestDragging, DragWindowOverlapShelf) {
EXPECT_TRUE(GetWindowOverlapsShelf());
}
// Verifies that when dragging a window autohidden shelf stays hidden during
// and after the drag.
TEST_P(WorkspaceControllerTestDragging, DragWindowKeepsShelfAutohidden) {
aura::test::TestWindowDelegate delegate;
delegate.set_window_component(HTCAPTION);
scoped_ptr<Window> w1(aura::test::CreateTestWindowWithDelegate(
&delegate, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 5, 100, 50), NULL));
ParentWindowInPrimaryRootWindow(w1.get());
ShelfLayoutManager* shelf = shelf_layout_manager();
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
// Drag very little.
aura::test::EventGenerator generator(
Shell::GetPrimaryRootWindow(), gfx::Point());
generator.MoveMouseTo(10, 10);
generator.PressLeftButton();
generator.MoveMouseTo(12, 12);
// Shelf should be hidden during and after the drag.
EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
generator.ReleaseLeftButton();
EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
}
INSTANTIATE_TEST_CASE_P(DockedOrNot, WorkspaceControllerTestDragging,
::testing::Bool());
......
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