Commit 93d9f7cf authored by varkha@chromium.org's avatar varkha@chromium.org

Update shelf when overlapping dragged windows exist

BUG=321704
TEST=ash_unittests --gtest_filter=*WorkspaceControllerTestDragging.DragWindowOverlapShelf*

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238507 0039d316-1c4b-4281-b951-d872f2087c98
parent 4bf8c63d
...@@ -483,6 +483,12 @@ void DockedWindowLayoutManager::SetChildBounds( ...@@ -483,6 +483,12 @@ void DockedWindowLayoutManager::SetChildBounds(
const gfx::Rect& requested_bounds) { const gfx::Rect& requested_bounds) {
// Whenever one of our windows is moved or resized enforce layout. // Whenever one of our windows is moved or resized enforce layout.
SetChildBoundsDirect(child, requested_bounds); SetChildBoundsDirect(child, requested_bounds);
if (IsPopupOrTransient(child))
return;
ShelfLayoutManager* shelf_layout = internal::ShelfLayoutManager::ForLauncher(
dock_container_);
if (shelf_layout)
shelf_layout->UpdateVisibilityState();
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
......
...@@ -58,27 +58,37 @@ WorkspaceWindowState WorkspaceController::GetWindowState() const { ...@@ -58,27 +58,37 @@ WorkspaceWindowState WorkspaceController::GetWindowState() const {
if (!shelf_) if (!shelf_)
return WORKSPACE_WINDOW_STATE_DEFAULT; return WORKSPACE_WINDOW_STATE_DEFAULT;
// These are the container ids of containers which may contain windows that
// may overlap the launcher shelf and affect its transparency.
const int kWindowContainerIds[] = {
internal::kShellWindowId_DefaultContainer,
internal::kShellWindowId_DockedContainer,
};
const gfx::Rect shelf_bounds(shelf_->GetIdealBounds()); const gfx::Rect shelf_bounds(shelf_->GetIdealBounds());
const aura::Window::Windows& windows(viewport_->children());
bool window_overlaps_launcher = false; bool window_overlaps_launcher = false;
bool has_maximized_window = false; bool has_maximized_window = false;
for (aura::Window::Windows::const_iterator i = windows.begin(); for (size_t idx = 0; idx < arraysize(kWindowContainerIds); idx++) {
i != windows.end(); ++i) { const aura::Window* container = Shell::GetContainer(
wm::WindowState* window_state = wm::GetWindowState(*i); viewport_->GetRootWindow(), kWindowContainerIds[idx]);
if (window_state->ignored_by_shelf()) const aura::Window::Windows& windows(container->children());
continue; for (aura::Window::Windows::const_iterator i = windows.begin();
ui::Layer* layer = (*i)->layer(); i != windows.end(); ++i) {
if (!layer->GetTargetVisibility() || layer->GetTargetOpacity() == 0.0f) wm::WindowState* window_state = wm::GetWindowState(*i);
continue; if (window_state->ignored_by_shelf())
if (window_state->IsMaximized()) { continue;
// An untracked window may still be fullscreen so we keep iterating when ui::Layer* layer = (*i)->layer();
// we hit a maximized window. if (!layer->GetTargetVisibility() || layer->GetTargetOpacity() == 0.0f)
has_maximized_window = true; continue;
} else if (window_state->IsFullscreen()) { if (window_state->IsMaximized()) {
return WORKSPACE_WINDOW_STATE_FULL_SCREEN; // An untracked window may still be fullscreen so we keep iterating when
// we hit a maximized window.
has_maximized_window = true;
} else if (window_state->IsFullscreen()) {
return WORKSPACE_WINDOW_STATE_FULL_SCREEN;
}
if (!window_overlaps_launcher && (*i)->bounds().Intersects(shelf_bounds))
window_overlaps_launcher = true;
} }
if (!window_overlaps_launcher && (*i)->bounds().Intersects(shelf_bounds))
window_overlaps_launcher = true;
} }
if (has_maximized_window) if (has_maximized_window)
return WORKSPACE_WINDOW_STATE_MAXIMIZED; return WORKSPACE_WINDOW_STATE_MAXIMIZED;
......
...@@ -1389,5 +1389,64 @@ TEST_F(WorkspaceControllerTest, SwitchFromModal) { ...@@ -1389,5 +1389,64 @@ TEST_F(WorkspaceControllerTest, SwitchFromModal) {
EXPECT_TRUE(maximized_window->IsVisible()); EXPECT_TRUE(maximized_window->IsVisible());
} }
namespace {
// Subclass of WorkspaceControllerTest that runs tests with docked windows
// enabled and disabled.
class WorkspaceControllerTestDragging
: public WorkspaceControllerTest,
public testing::WithParamInterface<bool> {
public:
WorkspaceControllerTestDragging() {}
virtual ~WorkspaceControllerTestDragging() {}
// testing::Test:
virtual void SetUp() OVERRIDE {
WorkspaceControllerTest::SetUp();
if (!docked_windows_enabled()) {
CommandLine::ForCurrentProcess()->AppendSwitch(
ash::switches::kAshDisableDockedWindows);
}
}
bool docked_windows_enabled() const { return GetParam(); }
private:
DISALLOW_COPY_AND_ASSIGN(WorkspaceControllerTestDragging);
};
} // namespace
// Verifies that when dragging a window over the shelf overlap is detected
// during and after the drag.
TEST_P(WorkspaceControllerTestDragging, DragWindowOverlapShelf) {
aura::test::TestWindowDelegate delegate;
delegate.set_window_component(HTCAPTION);
scoped_ptr<Window> w1(
aura::test::CreateTestWindowWithDelegate(&delegate,
aura::client::WINDOW_TYPE_NORMAL,
gfx::Rect(5, 5, 100, 50),
NULL));
ParentWindowInPrimaryRootWindow(w1.get());
ShelfLayoutManager* shelf = shelf_layout_manager();
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
// Drag near the shelf
aura::test::EventGenerator generator(
Shell::GetPrimaryRootWindow(), gfx::Point());
generator.MoveMouseTo(10, 10);
generator.PressLeftButton();
generator.MoveMouseTo(100, shelf->GetIdealBounds().y() - 20);
// Shelf should detect overlap. Overlap state stays after mouse is released.
EXPECT_TRUE(GetWindowOverlapsShelf());
generator.ReleaseLeftButton();
EXPECT_TRUE(GetWindowOverlapsShelf());
}
INSTANTIATE_TEST_CASE_P(DockedOrNot, WorkspaceControllerTestDragging,
::testing::Bool());
} // namespace internal } // namespace internal
} // namespace ash } // namespace ash
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