diff --git a/ash/wm/workspace/workspace_window_resizer.cc b/ash/wm/workspace/workspace_window_resizer.cc index 18fe6baeb9ebb2..ca7ca3f2c7e219 100644 --- a/ash/wm/workspace/workspace_window_resizer.cc +++ b/ash/wm/workspace/workspace_window_resizer.cc @@ -773,8 +773,10 @@ void WorkspaceWindowResizer::AdjustBoundsForMainWindow( ScreenAsh::ConvertRectFromScreen(window()->parent(), display.work_area()); if (details_.window_component == HTCAPTION) { // Adjust the bounds to the work area where the mouse cursor is located. - // Always keep kMinOnscreenHeight on the bottom. - int max_y = work_area.bottom() - kMinOnscreenHeight; + // Always keep kMinOnscreenHeight or the window height (whichever is less) + // on the bottom. + int max_y = work_area.bottom() - std::min(kMinOnscreenHeight, + bounds->height()); if (bounds->y() > max_y) { bounds->set_y(max_y); } else if (bounds->y() <= work_area.y()) { diff --git a/ash/wm/workspace/workspace_window_resizer_unittest.cc b/ash/wm/workspace/workspace_window_resizer_unittest.cc index 51de51b7de5d9e..fcad68acfd6d98 100644 --- a/ash/wm/workspace/workspace_window_resizer_unittest.cc +++ b/ash/wm/workspace/workspace_window_resizer_unittest.cc @@ -722,6 +722,23 @@ TEST_F(WorkspaceWindowResizerTest, DontDragOffBottomWithMultiDisplay) { Shell::GetInstance()->display_controller()->SetLayoutForCurrentDisplays( ash::DisplayLayout(ash::DisplayLayout::BOTTOM, 0)); + { + window_->SetBounds(gfx::Rect(100, 200, 300, 20)); + DCHECK_LT(window_->bounds().height(), + WorkspaceWindowResizer::kMinOnscreenHeight); + scoped_ptr resizer(WorkspaceWindowResizer::Create( + window_.get(), gfx::Point(), HTCAPTION, + aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); + ASSERT_TRUE(resizer.get()); + resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); + int expected_y = kRootHeight - window_->bounds().height() - 10; + // When the mouse cursor is in the primary display, the window cannot move + // on non-work area but can get all the way towards the bottom, + // restricted only by the window height. + EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x20", + window_->bounds().ToString()); + } + { window_->SetBounds(gfx::Rect(100, 200, 300, 400)); scoped_ptr resizer(WorkspaceWindowResizer::Create(