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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « views/window/window_win.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "views/window/window_win.h" 5 #include "views/window/window_win.h"
6 6
7 #include <shellapi.h> 7 #include <shellapi.h>
8 8
9 #include "app/gfx/canvas_paint.h" 9 #include "app/gfx/canvas_paint.h"
10 #include "app/gfx/font.h" 10 #include "app/gfx/font.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 WidgetWin::GetBounds(&bounds, true); 114 WidgetWin::GetBounds(&bounds, true);
115 return bounds; 115 return bounds;
116 } 116 }
117 117
118 gfx::Rect WindowWin::GetNormalBounds() const { 118 gfx::Rect WindowWin::GetNormalBounds() const {
119 // If we're in fullscreen mode, we've changed the normal bounds to the monitor 119 // If we're in fullscreen mode, we've changed the normal bounds to the monitor
120 // rect, so return the saved bounds instead. 120 // rect, so return the saved bounds instead.
121 if (IsFullscreen()) 121 if (IsFullscreen())
122 return gfx::Rect(saved_window_info_.window_rect); 122 return gfx::Rect(saved_window_info_.window_rect);
123 123
124 WINDOWPLACEMENT wp; 124 gfx::Rect bounds;
125 wp.length = sizeof(wp); 125 GetWindowBoundsAndMaximizedState(&bounds, NULL);
126 const bool ret = !!GetWindowPlacement(GetNativeView(), &wp); 126 return bounds;
127 DCHECK(ret);
128 return gfx::Rect(wp.rcNormalPosition);
129 } 127 }
130 128
131 void WindowWin::SetBounds(const gfx::Rect& bounds, 129 void WindowWin::SetBounds(const gfx::Rect& bounds,
132 gfx::NativeWindow other_window) { 130 gfx::NativeWindow other_window) {
133 win_util::SetChildBounds(GetNativeView(), GetParent(), other_window, bounds, 131 win_util::SetChildBounds(GetNativeView(), GetParent(), other_window, bounds,
134 kMonitorEdgePadding, 0); 132 kMonitorEdgePadding, 0);
135 } 133 }
136 134
137 void WindowWin::Show(int show_state) { 135 void WindowWin::Show(int show_state) {
138 ShowWindow(show_state); 136 ShowWindow(show_state);
(...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 } 1280 }
1283 1281
1284 void WindowWin::SaveWindowPosition() { 1282 void WindowWin::SaveWindowPosition() {
1285 // The window delegate does the actual saving for us. It seems like (judging 1283 // The window delegate does the actual saving for us. It seems like (judging
1286 // by go/crash) that in some circumstances we can end up here after 1284 // by go/crash) that in some circumstances we can end up here after
1287 // WM_DESTROY, at which point the window delegate is likely gone. So just 1285 // WM_DESTROY, at which point the window delegate is likely gone. So just
1288 // bail. 1286 // bail.
1289 if (!window_delegate_) 1287 if (!window_delegate_)
1290 return; 1288 return;
1291 1289
1292 WINDOWPLACEMENT win_placement = { 0 }; 1290 bool maximized;
1293 win_placement.length = sizeof(WINDOWPLACEMENT); 1291 gfx::Rect bounds;
1294 1292 GetWindowBoundsAndMaximizedState(&bounds, &maximized);
1295 BOOL r = GetWindowPlacement(GetNativeView(), &win_placement); 1293 window_delegate_->SaveWindowPlacement(bounds, maximized);
1296 DCHECK(r);
1297
1298 bool maximized = (win_placement.showCmd == SW_SHOWMAXIMIZED);
1299 CRect window_bounds(win_placement.rcNormalPosition);
1300 window_delegate_->SaveWindowPlacement(
1301 gfx::Rect(win_placement.rcNormalPosition), maximized);
1302 } 1294 }
1303 1295
1304 void WindowWin::LockUpdates() { 1296 void WindowWin::LockUpdates() {
1305 lock_updates_ = true; 1297 lock_updates_ = true;
1306 saved_window_style_ = GetWindowLong(GWL_STYLE); 1298 saved_window_style_ = GetWindowLong(GWL_STYLE);
1307 SetWindowLong(GWL_STYLE, saved_window_style_ & ~WS_VISIBLE); 1299 SetWindowLong(GWL_STYLE, saved_window_style_ & ~WS_VISIBLE);
1308 } 1300 }
1309 1301
1310 void WindowWin::UnlockUpdates() { 1302 void WindowWin::UnlockUpdates() {
1311 SetWindowLong(GWL_STYLE, saved_window_style_); 1303 SetWindowLong(GWL_STYLE, saved_window_style_);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1357 } 1349 }
1358 1350
1359 LRESULT WindowWin::CallDefaultNCActivateHandler(BOOL active) { 1351 LRESULT WindowWin::CallDefaultNCActivateHandler(BOOL active) {
1360 // The DefWindowProc handling for WM_NCACTIVATE renders the classic-look 1352 // The DefWindowProc handling for WM_NCACTIVATE renders the classic-look
1361 // window title bar directly, so we need to use a redraw lock here to prevent 1353 // window title bar directly, so we need to use a redraw lock here to prevent
1362 // it from doing so. 1354 // it from doing so.
1363 ScopedRedrawLock lock(this); 1355 ScopedRedrawLock lock(this);
1364 return DefWindowProc(GetNativeView(), WM_NCACTIVATE, active, 0); 1356 return DefWindowProc(GetNativeView(), WM_NCACTIVATE, active, 0);
1365 } 1357 }
1366 1358
1359 void WindowWin::GetWindowBoundsAndMaximizedState(gfx::Rect* bounds,
1360 bool* maximized) const {
1361 WINDOWPLACEMENT wp;
1362 wp.length = sizeof(wp);
1363 const bool succeeded = !!GetWindowPlacement(GetNativeView(), &wp);
1364 DCHECK(succeeded);
1365
1366 if (bounds != NULL) {
1367 MONITORINFO mi;
1368 mi.cbSize = sizeof(mi);
1369 const bool succeeded = !!GetMonitorInfo(
1370 MonitorFromWindow(GetNativeView(), MONITOR_DEFAULTTONEAREST), &mi);
1371 DCHECK(succeeded);
1372 *bounds = gfx::Rect(wp.rcNormalPosition);
1373 // Convert normal position from workarea coordinates to screen coordinates.
1374 bounds->Offset(mi.rcWork.left, mi.rcWork.top);
1375 }
1376
1377 if (maximized != NULL)
1378 *maximized = (wp.showCmd == SW_SHOWMAXIMIZED);
1379 }
1380
1367 void WindowWin::InitClass() { 1381 void WindowWin::InitClass() {
1368 static bool initialized = false; 1382 static bool initialized = false;
1369 if (!initialized) { 1383 if (!initialized) {
1370 resize_cursors_[RC_NORMAL] = LoadCursor(NULL, IDC_ARROW); 1384 resize_cursors_[RC_NORMAL] = LoadCursor(NULL, IDC_ARROW);
1371 resize_cursors_[RC_VERTICAL] = LoadCursor(NULL, IDC_SIZENS); 1385 resize_cursors_[RC_VERTICAL] = LoadCursor(NULL, IDC_SIZENS);
1372 resize_cursors_[RC_HORIZONTAL] = LoadCursor(NULL, IDC_SIZEWE); 1386 resize_cursors_[RC_HORIZONTAL] = LoadCursor(NULL, IDC_SIZEWE);
1373 resize_cursors_[RC_NESW] = LoadCursor(NULL, IDC_SIZENESW); 1387 resize_cursors_[RC_NESW] = LoadCursor(NULL, IDC_SIZENESW);
1374 resize_cursors_[RC_NWSE] = LoadCursor(NULL, IDC_SIZENWSE); 1388 resize_cursors_[RC_NWSE] = LoadCursor(NULL, IDC_SIZENWSE);
1375 initialized = true; 1389 initialized = true;
1376 } 1390 }
(...skipping 25 matching lines...) Expand all
1402 } 1416 }
1403 return TRUE; 1417 return TRUE;
1404 } 1418 }
1405 } // namespace 1419 } // namespace
1406 1420
1407 void Window::CloseAllSecondaryWindows() { 1421 void Window::CloseAllSecondaryWindows() {
1408 EnumThreadWindows(GetCurrentThreadId(), WindowCallbackProc, 0); 1422 EnumThreadWindows(GetCurrentThreadId(), WindowCallbackProc, 0);
1409 } 1423 }
1410 1424
1411 } // namespace views 1425 } // namespace views
OLDNEW
« 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