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

Unified Diff: ash/wm/window_util.cc

Issue 21979005: Make sure that 30%of restored window is always visible. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments Created 7 years, 4 months 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
« no previous file with comments | « ash/wm/property_util.h ('k') | ash/wm/workspace/workspace_event_handler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/window_util.cc
diff --git a/ash/wm/window_util.cc b/ash/wm/window_util.cc
index f11b3bc65d045579d2b968d9f9e0f846dbbe2f49..67dcd95c4c19ff6810c65cc1d8175e7f06a3045e 100644
--- a/ash/wm/window_util.cc
+++ b/ash/wm/window_util.cc
@@ -173,21 +173,19 @@ void AdjustBoundsToEnsureWindowVisibility(const gfx::Rect& work_area,
gfx::Rect* bounds) {
bounds->set_width(std::min(bounds->width(), work_area.width()));
bounds->set_height(std::min(bounds->height(), work_area.height()));
- if (!work_area.Intersects(*bounds)) {
- int y_offset = 0;
- if (work_area.bottom() < bounds->y()) {
- y_offset = work_area.bottom() - bounds->y() - min_height;
- } else if (bounds->bottom() < work_area.y()) {
- y_offset = work_area.y() - bounds->bottom() + min_height;
- }
-
- int x_offset = 0;
- if (work_area.right() < bounds->x()) {
- x_offset = work_area.right() - bounds->x() - min_width;
- } else if (bounds->right() < work_area.x()) {
- x_offset = work_area.x() - bounds->right() + min_width;
- }
- bounds->Offset(x_offset, y_offset);
+
+ min_width = std::min(min_width, work_area.width());
+ min_height = std::min(min_height, work_area.height());
+
+ if (bounds->x() + min_width > work_area.right()) {
+ bounds->set_x(work_area.right() - min_width);
+ } else if (bounds->right() - min_width < 0) {
+ bounds->set_x(min_width - bounds->width());
+ }
+ if (bounds->y() + min_height > work_area.bottom()) {
+ bounds->set_y(work_area.bottom() - min_height);
+ } else if (bounds->bottom() - min_height < 0) {
+ bounds->set_y(min_height - bounds->height());
}
}
« no previous file with comments | « ash/wm/property_util.h ('k') | ash/wm/workspace/workspace_event_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698