Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Unified Diff: views/window/window_win.cc

Issue 141039: For consistency, stop using the workarea coordinate in... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « views/window/window_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/window/window_win.cc
===================================================================
--- views/window/window_win.cc (revision 18780)
+++ views/window/window_win.cc (working copy)
@@ -121,11 +121,9 @@
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 @@
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 @@
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) {
« no previous file with comments | « views/window/window_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698