diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-13 08:21:27 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-13 08:21:27 +0000 |
commit | 4aa67549b1fad9188397e64bd7ca2358d69cde35 (patch) | |
tree | 0c01f07d815118577ca849f6d24fb753625cf951 /ash/wm/drag_window_resizer.cc | |
parent | 7ed2e46105ab0ead6ef8477719ada094e163b1b7 (diff) | |
download | chromium_src-4aa67549b1fad9188397e64bd7ca2358d69cde35.zip chromium_src-4aa67549b1fad9188397e64bd7ca2358d69cde35.tar.gz chromium_src-4aa67549b1fad9188397e64bd7ca2358d69cde35.tar.bz2 |
Make sure the dragged window is smaller than work area in the target display.
- makes sure that minimum amount of window is visible when dropped.
- When moving a window to another due to display disconnect, try to keep relative position in the work are, rather than absolute position to the root window.
BUG=321702
TEST=covered by test
RootWindowController::MoveWindows_Basic
DragWindowResizerTest::WindowDragWithMultiDisplays
Review URL: https://codereview.chromium.org/93873013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240542 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/wm/drag_window_resizer.cc')
-rw-r--r-- | ash/wm/drag_window_resizer.cc | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/ash/wm/drag_window_resizer.cc b/ash/wm/drag_window_resizer.cc index 000d119..a524d67 100644 --- a/ash/wm/drag_window_resizer.cc +++ b/ash/wm/drag_window_resizer.cc @@ -125,9 +125,29 @@ void DragWindowResizer::CompleteDrag(int event_flags) { if (dst_display.id() != screen->GetDisplayNearestWindow(GetTarget()->GetRootWindow()).id()) { - const gfx::Rect dst_bounds = - ScreenAsh::ConvertRectToScreen(GetTarget()->parent(), - GetTarget()->bounds()); + // Adjust the size and position so that it doesn't exceed the size of + // work area. + const gfx::Size& size = dst_display.work_area().size(); + gfx::Rect bounds = GetTarget()->bounds(); + if (bounds.width() > size.width()) { + int diff = bounds.width() - size.width(); + bounds.set_x(bounds.x() + diff / 2); + bounds.set_width(size.width()); + } + if (bounds.height() > size.height()) + bounds.set_height(size.height()); + + gfx::Rect dst_bounds = + ScreenAsh::ConvertRectToScreen(GetTarget()->parent(), bounds); + + // Adjust the position so that the cursor is on the window. + if (!dst_bounds.Contains(last_mouse_location_in_screen)) { + if (last_mouse_location_in_screen.x() < dst_bounds.x()) + dst_bounds.set_x(last_mouse_location_in_screen.x()); + else if (last_mouse_location_in_screen.x() > dst_bounds.right()) + dst_bounds.set_x( + last_mouse_location_in_screen.x() - dst_bounds.width()); + } GetTarget()->SetBoundsInScreen(dst_bounds, dst_display); } } |