| Index: ash/wm/drag_window_resizer.cc
|
| diff --git a/ash/wm/drag_window_resizer.cc b/ash/wm/drag_window_resizer.cc
|
| index 000d1198419d9d40656f89f97839ebf1bb8813e3..a524d672181037413c934f859d7799d0526d4888 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);
|
| }
|
| }
|
|
|