summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authoryuzo@chromium.org <yuzo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-23 08:11:28 +0000
committeryuzo@chromium.org <yuzo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-23 08:11:28 +0000
commitc0ba0da8a6c0d0cd33acf46441b0d2edc63b16c4 (patch)
tree3fe96b3360d076c35544282145c7a1a71be6442a /views
parentf6555adcd5160d011ea1dc613fa0387dcddd0b6b (diff)
downloadchromium_src-c0ba0da8a6c0d0cd33acf46441b0d2edc63b16c4.zip
chromium_src-c0ba0da8a6c0d0cd33acf46441b0d2edc63b16c4.tar.gz
chromium_src-c0ba0da8a6c0d0cd33acf46441b0d2edc63b16c4.tar.bz2
For consistency, stop using the workarea coordinate in
saving/retrieving/adjusting window positions. TEST=Open Chrome windows and see if they are placed properly. TESTED=gcl try, manually BUG=none Review URL: http://codereview.chromium.org/141039 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19012 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rwxr-xr-xviews/window/window_win.cc44
-rw-r--r--views/window/window_win.h5
2 files changed, 34 insertions, 15 deletions
diff --git a/views/window/window_win.cc b/views/window/window_win.cc
index fc809932..52d7704 100755
--- a/views/window/window_win.cc
+++ b/views/window/window_win.cc
@@ -121,11 +121,9 @@ gfx::Rect WindowWin::GetNormalBounds() const {
if (IsFullscreen())
return gfx::Rect(saved_window_info_.window_rect);
- WINDOWPLACEMENT wp;
- wp.length = sizeof(wp);
- const bool ret = !!GetWindowPlacement(GetNativeView(), &wp);
- DCHECK(ret);
- return gfx::Rect(wp.rcNormalPosition);
+ gfx::Rect bounds;
+ GetWindowBoundsAndMaximizedState(&bounds, NULL);
+ return bounds;
}
void WindowWin::SetBounds(const gfx::Rect& bounds,
@@ -1289,16 +1287,10 @@ void WindowWin::SaveWindowPosition() {
if (!window_delegate_)
return;
- WINDOWPLACEMENT win_placement = { 0 };
- win_placement.length = sizeof(WINDOWPLACEMENT);
-
- BOOL r = GetWindowPlacement(GetNativeView(), &win_placement);
- DCHECK(r);
-
- bool maximized = (win_placement.showCmd == SW_SHOWMAXIMIZED);
- CRect window_bounds(win_placement.rcNormalPosition);
- window_delegate_->SaveWindowPlacement(
- gfx::Rect(win_placement.rcNormalPosition), maximized);
+ bool maximized;
+ gfx::Rect bounds;
+ GetWindowBoundsAndMaximizedState(&bounds, &maximized);
+ window_delegate_->SaveWindowPlacement(bounds, maximized);
}
void WindowWin::LockUpdates() {
@@ -1364,6 +1356,28 @@ LRESULT WindowWin::CallDefaultNCActivateHandler(BOOL active) {
return DefWindowProc(GetNativeView(), WM_NCACTIVATE, active, 0);
}
+void WindowWin::GetWindowBoundsAndMaximizedState(gfx::Rect* bounds,
+ bool* maximized) const {
+ WINDOWPLACEMENT wp;
+ wp.length = sizeof(wp);
+ const bool succeeded = !!GetWindowPlacement(GetNativeView(), &wp);
+ DCHECK(succeeded);
+
+ if (bounds != NULL) {
+ MONITORINFO mi;
+ mi.cbSize = sizeof(mi);
+ const bool succeeded = !!GetMonitorInfo(
+ MonitorFromWindow(GetNativeView(), MONITOR_DEFAULTTONEAREST), &mi);
+ DCHECK(succeeded);
+ *bounds = gfx::Rect(wp.rcNormalPosition);
+ // Convert normal position from workarea coordinates to screen coordinates.
+ bounds->Offset(mi.rcWork.left, mi.rcWork.top);
+ }
+
+ if (maximized != NULL)
+ *maximized = (wp.showCmd == SW_SHOWMAXIMIZED);
+}
+
void WindowWin::InitClass() {
static bool initialized = false;
if (!initialized) {
diff --git a/views/window/window_win.h b/views/window/window_win.h
index b6b9122..5f6a07b 100644
--- a/views/window/window_win.h
+++ b/views/window/window_win.h
@@ -201,6 +201,11 @@ class WindowWin : public WidgetWin,
// flicker.
LRESULT CallDefaultNCActivateHandler(BOOL active);
+ // Returns the normal bounds of the window in screen coordinates and
+ // whether the window is maximized. The arguments can be NULL.
+ void GetWindowBoundsAndMaximizedState(gfx::Rect* bounds,
+ bool* maximized) const;
+
// Static resource initialization.
static void InitClass();
enum ResizeCursor {