Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(396)

Unified Diff: ash/wm/drag_window_resizer.cc

Issue 93873013: Make sure the dragged window is smaller than work area in the target display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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());
varkha 2013/12/12 16:20:46 Is this enough for a vertical arrangement where th
oshima 2013/12/12 19:07:14 I don't think the screen layout does matter. I had
varkha 2013/12/12 22:10:47 I understand - we are probably never shrinking the
+
+ 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());
varkha 2013/12/12 16:20:46 Same here - does it consider vertical screen arran
varkha 2013/12/12 22:10:47 sg. Thanks for the explanation.
+ }
GetTarget()->SetBoundsInScreen(dst_bounds, dst_display);
}
}

Powered by Google App Engine
This is Rietveld 408576698