diff options
author | varkha@chromium.org <varkha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-06 20:31:04 +0000 |
---|---|---|
committer | varkha@chromium.org <varkha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-06 20:31:04 +0000 |
commit | 36334e09c193e28f686d4a5a6ca6c78d3dad7de1 (patch) | |
tree | 5cd8ec8e71248d86ed6c614daff92342c1af3e27 /ash/wm | |
parent | 74ae97e1509555378f648d67c0ae8ad32d285c2d (diff) | |
download | chromium_src-36334e09c193e28f686d4a5a6ca6c78d3dad7de1.zip chromium_src-36334e09c193e28f686d4a5a6ca6c78d3dad7de1.tar.gz chromium_src-36334e09c193e28f686d4a5a6ca6c78d3dad7de1.tar.bz2 |
Enforces 10px visibility when dragging between displays. This scenario is possibly overlooked in https://codereview.chromium.org/21979005.
BUG=314696
TEST=ash_unittests --gtest_filter=*WindowDragWithMultiDisplays:*WindowDragWithMultiDisplaysRightToLeft
Review URL: https://codereview.chromium.org/57963003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233344 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/wm')
-rw-r--r-- | ash/wm/dock/docked_window_resizer.cc | 6 | ||||
-rw-r--r-- | ash/wm/drag_window_resizer_unittest.cc | 16 | ||||
-rw-r--r-- | ash/wm/window_resizer.cc | 13 |
3 files changed, 24 insertions, 11 deletions
diff --git a/ash/wm/dock/docked_window_resizer.cc b/ash/wm/dock/docked_window_resizer.cc index 02d1733..f9a8df0 100644 --- a/ash/wm/dock/docked_window_resizer.cc +++ b/ash/wm/dock/docked_window_resizer.cc @@ -126,8 +126,7 @@ void DockedWindowResizer::CompleteDrag(int event_flags) { // windows. wm::WindowState* window_state = wm::GetWindowState(GetTarget()); bool was_tracked_by_workspace = window_state->tracked_by_workspace(); - if (was_docked_) - window_state->SetTrackedByWorkspace(false); + window_state->SetTrackedByWorkspace(false); // The root window can change when dragging into a different screen. next_window_resizer_->CompleteDrag(event_flags); FinishedDragging(); @@ -140,8 +139,7 @@ void DockedWindowResizer::RevertDrag() { // windows. wm::WindowState* window_state = wm::GetWindowState(GetTarget()); bool was_tracked_by_workspace = window_state->tracked_by_workspace(); - if (was_docked_) - window_state->SetTrackedByWorkspace(false); + window_state->SetTrackedByWorkspace(false); next_window_resizer_->RevertDrag(); // Restore docked state to what it was before the drag if necessary. if (is_docked_ != was_docked_) { diff --git a/ash/wm/drag_window_resizer_unittest.cc b/ash/wm/drag_window_resizer_unittest.cc index 844cbaa..cca570d 100644 --- a/ash/wm/drag_window_resizer_unittest.cc +++ b/ash/wm/drag_window_resizer_unittest.cc @@ -13,6 +13,7 @@ #include "ash/test/cursor_manager_test_api.h" #include "ash/wm/drag_window_controller.h" #include "ash/wm/window_util.h" +#include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" #include "ui/aura/client/aura_constants.h" #include "ui/aura/root_window.h" @@ -191,10 +192,13 @@ TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplays) { scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( window_.get(), gfx::Point(), HTCAPTION)); ASSERT_TRUE(resizer.get()); - resizer->Drag(CalculateDragPoint(*resizer, 790, 10), 0); + resizer->Drag(CalculateDragPoint(*resizer, 795, 10), 0); + // Window should be adjusted for minimum visibility (10px) during the drag. + EXPECT_EQ("790,10 50x60", window_->bounds().ToString()); resizer->CompleteDrag(0); // Since the pointer is still on the primary root window, the parent should // not be changed. + // Window origin should be adjusted for minimum visibility (10px). EXPECT_EQ(root_windows[0], window_->GetRootWindow()); EXPECT_EQ("790,10 50x60", window_->bounds().ToString()); } @@ -214,7 +218,10 @@ TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplays) { // even though only small fraction of the window is within the secondary // root window's bounds. EXPECT_EQ(root_windows[1], window_->GetRootWindow()); - EXPECT_EQ("-49,10 50x60", window_->bounds().ToString()); + // Window origin should be adjusted for minimum visibility (10px). + int expected_x = -50 + 10; + EXPECT_EQ(base::IntToString(expected_x) + ",10 50x60", + window_->bounds().ToString()); } } @@ -280,7 +287,10 @@ TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysRightToLeft) { resizer->Drag(CalculateDragPoint(*resizer, -2, 0), ui::EF_CONTROL_DOWN); resizer->CompleteDrag(0); EXPECT_EQ(root_windows[0], window_->GetRootWindow()); - EXPECT_EQ("798,0 50x60", window_->bounds().ToString()); + // Window origin should be adjusted for minimum visibility (10px). + int expected_x = 800 - 10; + EXPECT_EQ(base::IntToString(expected_x) + ",0 50x60", + window_->bounds().ToString()); } } diff --git a/ash/wm/window_resizer.cc b/ash/wm/window_resizer.cc index 65b390a..372ce48 100644 --- a/ash/wm/window_resizer.cc +++ b/ash/wm/window_resizer.cc @@ -263,12 +263,15 @@ gfx::Rect WindowResizer::CalculateBoundsForDrag( // the |work_area| above isn't good for this check since it is the work area // for the current display but the window can move to a different one. aura::Window* parent = details.window->parent(); - gfx::Rect new_bounds_in_screen = - ScreenAsh::ConvertRectToScreen(parent, new_bounds); + gfx::Point passed_location_in_screen(passed_location); + wm::ConvertPointToScreen(parent, &passed_location_in_screen); + gfx::Rect near_passed_location(passed_location_in_screen, gfx::Size()); + // Use a pointer location (matching the logic in DragWindowResizer) to + // calculate the target display after the drag. const gfx::Display& display = - Shell::GetScreen()->GetDisplayMatching(new_bounds_in_screen); + Shell::GetScreen()->GetDisplayMatching(near_passed_location); aura::Window* dock_container = Shell::GetContainer( - wm::GetRootWindowMatching(new_bounds_in_screen), + wm::GetRootWindowMatching(near_passed_location), internal::kShellWindowId_DockedContainer); internal::DockedWindowLayoutManager* dock_layout = static_cast<internal::DockedWindowLayoutManager*>( @@ -277,6 +280,8 @@ gfx::Rect WindowResizer::CalculateBoundsForDrag( gfx::Rect screen_work_area = display.work_area(); screen_work_area.Union(dock_layout->docked_bounds()); screen_work_area.Inset(kMinimumOnScreenArea, 0); + gfx::Rect new_bounds_in_screen = + ScreenAsh::ConvertRectToScreen(parent, new_bounds); if (!screen_work_area.Intersects(new_bounds_in_screen)) { // Make sure that the x origin does not leave the current display. new_bounds_in_screen.set_x( |