summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/window_sizer.cc2
-rw-r--r--chrome/browser/window_sizer_unittest.cc4
-rwxr-xr-xviews/window/window_win.cc44
-rw-r--r--views/window/window_win.h5
4 files changed, 36 insertions, 19 deletions
diff --git a/chrome/browser/window_sizer.cc b/chrome/browser/window_sizer.cc
index 59eed33..10e3cb9 100644
--- a/chrome/browser/window_sizer.cc
+++ b/chrome/browser/window_sizer.cc
@@ -151,7 +151,6 @@ bool WindowSizer::GetLastWindowBounds(gfx::Rect* bounds) const {
if (!state_provider_ || !state_provider_->GetLastActiveWindowState(bounds))
return false;
gfx::Rect last_window_bounds = *bounds;
- bounds->Offset(monitor_info_provider_->GetBoundsOffsetMatching(*bounds));
bounds->Offset(kWindowTilePixels, kWindowTilePixels);
AdjustBoundsToBeVisibleOnMonitorContaining(last_window_bounds, bounds);
return true;
@@ -163,7 +162,6 @@ bool WindowSizer::GetSavedWindowBounds(gfx::Rect* bounds,
if (!state_provider_ ||
!state_provider_->GetPersistentState(bounds, maximized))
return false;
- bounds->Offset(monitor_info_provider_->GetBoundsOffsetMatching(*bounds));
AdjustBoundsToBeVisibleOnMonitorContaining(*bounds, bounds);
return true;
}
diff --git a/chrome/browser/window_sizer_unittest.cc b/chrome/browser/window_sizer_unittest.cc
index 552a340..a3e5ecd9 100644
--- a/chrome/browser/window_sizer_unittest.cc
+++ b/chrome/browser/window_sizer_unittest.cc
@@ -268,7 +268,7 @@ TEST(WindowSizerTest, LastWindowBoundsCase) {
gfx::Rect(10, 10, 500, 400), false, LAST_ACTIVE,
&window_bounds, &maximized);
EXPECT_FALSE(maximized);
- EXPECT_EQ(gfx::Rect(127, 20, 500, 400), window_bounds);
+ EXPECT_EQ(gfx::Rect(20, 20, 500, 400), window_bounds);
}
{ // taskbar on top.
@@ -278,7 +278,7 @@ TEST(WindowSizerTest, LastWindowBoundsCase) {
gfx::Rect(10, 10, 500, 400), false, LAST_ACTIVE,
&window_bounds, &maximized);
EXPECT_FALSE(maximized);
- EXPECT_EQ(gfx::Rect(20, 54, 500, 400), window_bounds);
+ EXPECT_EQ(gfx::Rect(20, 20, 500, 400), window_bounds);
}
{ // too small to satisify the minimum visibility condition.
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 {