diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-28 17:39:40 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-28 17:39:40 +0000 |
commit | a6eb6c02c42b32cbd363ef599f805e18565f4f6b (patch) | |
tree | d2a1e73d8422728ed41b4fe59cf09de6d365bace /views/screen_win.cc | |
parent | 2fba276d4c3f693b87e0df88e6ea0f8dcb1a5e8e (diff) | |
download | chromium_src-a6eb6c02c42b32cbd363ef599f805e18565f4f6b.zip chromium_src-a6eb6c02c42b32cbd363ef599f805e18565f4f6b.tar.gz chromium_src-a6eb6c02c42b32cbd363ef599f805e18565f4f6b.tar.bz2 |
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
Diffstat (limited to 'views/screen_win.cc')
-rw-r--r-- | views/screen_win.cc | 22 |
1 files changed, 15 insertions, 7 deletions
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() { |