From a6eb6c02c42b32cbd363ef599f805e18565f4f6b Mon Sep 17 00:00:00 2001 From: "sky@chromium.org" Date: Fri, 28 Jan 2011 17:39:40 +0000 Subject: Lands http://codereview.chromium.org/6380007/ for jamiewalch Don't allow new windows to be created outside the monitor's work area. BUG=281 TEST=Drag a tab down to the bottom of the screen. Check that the new window is created with its border accessible. Review URL: http://codereview.chromium.org/6335019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72970 0039d316-1c4b-4281-b951-d872f2087c98 --- views/screen_win.cc | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'views/screen_win.cc') diff --git a/views/screen_win.cc b/views/screen_win.cc index 4ddb7c1..b24a55c 100644 --- a/views/screen_win.cc +++ b/views/screen_win.cc @@ -33,17 +33,25 @@ gfx::Rect Screen::GetMonitorAreaNearestWindow(gfx::NativeWindow window) { return gfx::Rect(monitor_info.rcMonitor); } -// static -gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) { +static gfx::Rect GetMonitorAreaOrWorkAreaNearestPoint(const gfx::Point& point, + bool work_area) { POINT initial_loc = { point.x(), point.y() }; HMONITOR monitor = MonitorFromPoint(initial_loc, MONITOR_DEFAULTTONEAREST); - if (!monitor) - return gfx::Rect(); - MONITORINFO mi = {0}; mi.cbSize = sizeof(mi); - GetMonitorInfo(monitor, &mi); - return gfx::Rect(mi.rcMonitor); + if (monitor && GetMonitorInfo(monitor, &mi)) + return gfx::Rect(work_area ? mi.rcWork : mi.rcMonitor); + return gfx::Rect(); +} + +// static +gfx::Rect Screen::GetMonitorWorkAreaNearestPoint(const gfx::Point& point) { + return GetMonitorAreaOrWorkAreaNearestPoint(point, true); +} + +// static +gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) { + return GetMonitorAreaOrWorkAreaNearestPoint(point, false); } gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() { -- cgit v1.1