1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome_frame/infobars/internal/displaced_window_manager.h"
7 DisplacedWindowManager::DisplacedWindowManager() {
10 void DisplacedWindowManager::UpdateLayout() {
11 // Call SetWindowPos with SWP_FRAMECHANGED for displaced window.
12 // Displaced window will receive WM_NCCALCSIZE to recalculate its client size.
13 ::SetWindowPos(m_hWnd
,
15 SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOSIZE
| SWP_NOZORDER
|
19 LRESULT
DisplacedWindowManager::OnNcCalcSize(BOOL calc_valid_rects
,
21 // Ask the original window proc to calculate the 'natural' size of the window.
22 LRESULT ret
= DefWindowProc(WM_NCCALCSIZE
,
23 static_cast<WPARAM
>(calc_valid_rects
), lparam
);
27 // Whether calc_valid_rects is true or false, we could treat beginning of
28 // lparam as a RECT object.
29 RECT
* rect
= reinterpret_cast<RECT
*>(lparam
);
30 RECT natural_rect
= *rect
;
31 if (delegate() != NULL
)
32 delegate()->AdjustDisplacedWindowDimensions(rect
);
34 // If we modified the window's dimensions, there is no way to respect a custom
35 // "client-area preservation strategy", so we must force a redraw to be safe.
36 if (calc_valid_rects
&& ret
== WVR_VALIDRECTS
&&
37 !EqualRect(&natural_rect
, rect
)) {