| 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,
|
|
|