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

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: 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
Index: ash/wm/window_util.cc
diff --git a/ash/wm/window_util.cc b/ash/wm/window_util.cc
index f11b3bc65d045579d2b968d9f9e0f846dbbe2f49..b41cfdd45fe1d1b9ffb16fcdde5dda100a78405d 100644
--- a/ash/wm/window_util.cc
+++ b/ash/wm/window_util.cc
@@ -173,21 +173,16 @@ void AdjustBoundsToEnsureWindowVisibility(const gfx::Rect& work_area,
gfx::Rect* bounds) {
bounds->set_width(std::min(bounds->width(), work_area.width()));
Mr4D (OOO till 08-26) 2013/08/06 20:22:51 I assume this is not really a problem - but what i
oshima 2013/08/06 23:13:20 min_width/min_height shouldn't be bigger than wrok
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);
+
+ 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());
Mr4D (OOO till 08-26) 2013/08/06 20:22:51 Indenting incorrect.
oshima 2013/08/06 23:13:20 Done.
+ }
+ if (bounds->y() + min_height > work_area.height()) {
Mr4D (OOO till 08-26) 2013/08/06 20:22:51 work_Area.height is probably not correct. Shouldn'
oshima 2013/08/06 23:13:20 You're right. fixed.
+ bounds->set_y(work_area.bottom() - min_height);
+ } else if (bounds->bottom() - min_height < 0) {
+ bounds->set_y(min_height - bounds->height());
}
}

Powered by Google App Engine
This is Rietveld 408576698