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

Unified Diff: ui/base/win/hwnd_util.cc

Issue 9346026: For child windows, use parent coordinate system and bounds (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/win/hwnd_util.cc
===================================================================
--- ui/base/win/hwnd_util.cc (revision 120775)
+++ ui/base/win/hwnd_util.cc (working copy)
@@ -14,7 +14,7 @@
namespace {
// Adjust the window to fit, returning true if the window was resized or moved.
-bool AdjustWindowToFit(HWND hwnd, const RECT& bounds) {
+bool AdjustWindowToFit(HWND window, HWND parent, const RECT& bounds) {
// Get the monitor.
HMONITOR hmon = MonitorFromRect(&bounds, MONITOR_DEFAULTTONEAREST);
if (!hmon) {
@@ -27,11 +27,19 @@
mi.cbSize = sizeof(mi);
GetMonitorInfo(hmon, &mi);
gfx::Rect window_rect(bounds);
- gfx::Rect monitor_rect(mi.rcWork);
- gfx::Rect new_window_rect = window_rect.AdjustToFit(monitor_rect);
+ gfx::Rect fit_bounds;
+ if (::GetWindowLong(window, GWL_STYLE) & WS_CHILD) {
+ RECT parent_rect;
+ ::GetWindowRect(parent, &parent_rect);
+ fit_bounds = parent_rect;
+ fit_bounds.Offset(-parent_rect.left, -parent_rect.top);
+ } else {
+ fit_bounds = mi.rcWork;
+ }
+ gfx::Rect new_window_rect = window_rect.AdjustToFit(fit_bounds);
if (!new_window_rect.Equals(window_rect)) {
// Window doesn't fit on monitor, move and possibly resize.
- SetWindowPos(hwnd, 0, new_window_rect.x(), new_window_rect.y(),
+ SetWindowPos(window, 0, new_window_rect.x(), new_window_rect.y(),
new_window_rect.width(), new_window_rect.height(),
SWP_NOACTIVATE | SWP_NOZORDER);
return true;
@@ -158,7 +166,7 @@
if (!pref_is_client ||
AdjustWindowRectEx(&window_bounds, win_info.dwStyle, FALSE,
win_info.dwExStyle)) {
- if (!AdjustWindowToFit(window, window_bounds)) {
+ if (!AdjustWindowToFit(window, parent, window_bounds)) {
// The window fits, reset the bounds.
SetWindowPos(window, 0, window_bounds.left, window_bounds.top,
window_bounds.right - window_bounds.left,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698