Skip to content

Commit

Permalink
Allow a window to get all the way to the bottom of work area for smal…
Browse files Browse the repository at this point in the history
…l windows. Previously restricted with a margin of WorkspaceWindowResizer::kMinOnscreenHeight (32) so short windows could not be dragged all the way to the bottom of the work area.

BUG=None
TEST=ash_unittests --gtest_filter=*DontDragOffBottomWithMultiDisplay*

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225886 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
varkha@chromium.org committed Sep 29, 2013
1 parent d554c4a commit fe57f39
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ash/wm/workspace/workspace_window_resizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
17 changes: 17 additions & 0 deletions ash/wm/workspace/workspace_window_resizer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<WorkspaceWindowResizer> 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<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
Expand Down

0 comments on commit fe57f39

Please sign in to comment.