summaryrefslogtreecommitdiffstats
path: root/chrome/browser/window_sizer.cc
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-13 01:47:10 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-13 01:47:10 +0000
commit85d188a54ea7f78d43db31087ce1abd1b82726dd (patch)
treed9fa2f269c26b069bb3e03626b837db6ac33538d /chrome/browser/window_sizer.cc
parentd185b2fd15adfee5cad70656545d66440c6b2113 (diff)
downloadchromium_src-85d188a54ea7f78d43db31087ce1abd1b82726dd.zip
chromium_src-85d188a54ea7f78d43db31087ce1abd1b82726dd.tar.gz
chromium_src-85d188a54ea7f78d43db31087ce1abd1b82726dd.tar.bz2
Try and make the GetXXXBounds() functions share more code to be shorter, and change a name to make it a bit clearer. No user-visible change.
Review URL: http://codereview.chromium.org/21332 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9726 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/window_sizer.cc')
-rw-r--r--chrome/browser/window_sizer.cc39
1 files changed, 17 insertions, 22 deletions
diff --git a/chrome/browser/window_sizer.cc b/chrome/browser/window_sizer.cc
index 596a7c8..eddb42b 100644
--- a/chrome/browser/window_sizer.cc
+++ b/chrome/browser/window_sizer.cc
@@ -28,40 +28,28 @@ class DefaultMonitorInfoProvider : public WindowSizer::MonitorInfoProvider {
// Overridden from WindowSizer::MonitorInfoProvider:
virtual gfx::Rect GetPrimaryMonitorWorkingRect() const {
- HMONITOR monitor = MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY);
- MONITORINFO monitor_info;
- monitor_info.cbSize = sizeof(monitor_info);
- GetMonitorInfo(monitor, &monitor_info);
- return gfx::Rect(monitor_info.rcWork);
+ return gfx::Rect(GetMonitorInfoForMonitor(MonitorFromWindow(NULL,
+ MONITOR_DEFAULTTOPRIMARY)).rcWork);
}
virtual gfx::Rect GetPrimaryMonitorBounds() const {
- HMONITOR monitor = MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY);
- MONITORINFO monitor_info;
- monitor_info.cbSize = sizeof(monitor_info);
- GetMonitorInfo(monitor, &monitor_info);
- return gfx::Rect(monitor_info.rcMonitor);
+ return gfx::Rect(GetMonitorInfoForMonitor(MonitorFromWindow(NULL,
+ MONITOR_DEFAULTTOPRIMARY)).rcMonitor);
}
- virtual gfx::Rect GetMonitorBoundsMatching(
+ virtual gfx::Rect GetMonitorWorkingRectMatching(
const gfx::Rect& match_rect) const {
CRect other_bounds_crect = match_rect.ToRECT();
- HMONITOR monitor =
- MonitorFromRect(&other_bounds_crect, MONITOR_DEFAULTTOPRIMARY);
- MONITORINFO monitor_info;
- monitor_info.cbSize = sizeof(monitor_info);
- GetMonitorInfo(monitor, &monitor_info);
+ MONITORINFO monitor_info = GetMonitorInfoForMonitor(MonitorFromRect(
+ &other_bounds_crect, MONITOR_DEFAULTTOPRIMARY));
return gfx::Rect(monitor_info.rcWork);
}
virtual gfx::Point GetBoundsOffsetMatching(
const gfx::Rect& match_rect) const {
CRect other_bounds_crect = match_rect.ToRECT();
- HMONITOR monitor =
- MonitorFromRect(&other_bounds_crect, MONITOR_DEFAULTTOPRIMARY);
- MONITORINFO monitor_info;
- monitor_info.cbSize = sizeof(monitor_info);
- GetMonitorInfo(monitor, &monitor_info);
+ MONITORINFO monitor_info = GetMonitorInfoForMonitor(MonitorFromRect(
+ &other_bounds_crect, MONITOR_DEFAULTTOPRIMARY));
return gfx::Point(monitor_info.rcWork.left - monitor_info.rcMonitor.left,
monitor_info.rcWork.top - monitor_info.rcMonitor.top);
}
@@ -91,6 +79,13 @@ class DefaultMonitorInfoProvider : public WindowSizer::MonitorInfoProvider {
return TRUE;
}
+ static MONITORINFO GetMonitorInfoForMonitor(HMONITOR monitor) {
+ MONITORINFO monitor_info;
+ monitor_info.cbSize = sizeof(monitor_info);
+ GetMonitorInfo(monitor, &monitor_info);
+ return monitor_info;
+ }
+
std::vector<gfx::Rect> working_rects_;
DISALLOW_EVIL_CONSTRUCTORS(DefaultMonitorInfoProvider);
@@ -307,7 +302,7 @@ void WindowSizer::AdjustBoundsToBeVisibleOnMonitorContaining(
// Find the size of the work area of the monitor that intersects the bounds
// of the anchor window.
gfx::Rect work_area =
- monitor_info_provider_->GetMonitorBoundsMatching(other_bounds);
+ monitor_info_provider_->GetMonitorWorkingRectMatching(other_bounds);
// If height or width are 0, reset to the default size.
gfx::Rect default_bounds;