summaryrefslogtreecommitdiffstats
path: root/chrome/browser/window_sizer.cc
diff options
context:
space:
mode:
authorrohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-21 19:27:49 +0000
committerrohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-21 19:27:49 +0000
commit0b61b98ba755f5b012a3486077fefd41c7a245ea (patch)
tree861facd74ded3d85eaf07c64fefa571b1af88dde /chrome/browser/window_sizer.cc
parent68e072e1a4a3408bd4e2f3bde4dc89e028b0889e (diff)
downloadchromium_src-0b61b98ba755f5b012a3486077fefd41c7a245ea.zip
chromium_src-0b61b98ba755f5b012a3486077fefd41c7a245ea.tar.gz
chromium_src-0b61b98ba755f5b012a3486077fefd41c7a245ea.tar.bz2
[Mac] Be more aggressive in repositioning windows that are offscreen.
BUG=http://crbug.com/18713 TEST=Windows that can fit entirely onscreen should appear entirely onscreen. Review URL: http://codereview.chromium.org/293052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29688 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/window_sizer.cc')
-rw-r--r--chrome/browser/window_sizer.cc16
1 files changed, 14 insertions, 2 deletions
diff --git a/chrome/browser/window_sizer.cc b/chrome/browser/window_sizer.cc
index 1438e32..0a76a7b 100644
--- a/chrome/browser/window_sizer.cc
+++ b/chrome/browser/window_sizer.cc
@@ -305,13 +305,25 @@ void WindowSizer::AdjustBoundsToBeVisibleOnMonitorContaining(
// to shrink it again. Windows does not have this limitation
// (e.g. can be resized from the top).
bounds->set_height(std::min(work_area.height(), bounds->height()));
-#endif // defined(OS_MACOSX)
- // Ensure at least kMinVisibleWidth * kMinVisibleHeight is visible.
+ // On mac, we want to be aggressive about repositioning windows that are
+ // partially offscreen. If the window is partially offscreen horizontally,
+ // move it to be flush with the left edge of the work area.
+ if (bounds->x() < work_area.x() || bounds->right() > work_area.right())
+ bounds->set_x(work_area.x());
+
+ // If the window is partially offscreen vertically, move it to be flush with
+ // the top of the work area.
+ if (bounds->y() < work_area.y() || bounds->bottom() > work_area.bottom())
+ bounds->set_y(work_area.y());
+#else
+ // On non-Mac platforms, we are less aggressive about repositioning. Simply
+ // ensure that at least kMinVisibleWidth * kMinVisibleHeight is visible.
const int min_y = work_area.y() + kMinVisibleHeight - bounds->height();
const int min_x = work_area.x() + kMinVisibleWidth - bounds->width();
const int max_y = work_area.bottom() - kMinVisibleHeight;
const int max_x = work_area.right() - kMinVisibleWidth;
bounds->set_y(std::max(min_y, std::min(max_y, bounds->y())));
bounds->set_x(std::max(min_x, std::min(max_x, bounds->x())));
+#endif // defined(OS_MACOSX)
}