Commit 141defbd authored by Alexandre Julliard's avatar Alexandre Julliard

user32: Use WIN_GetRectangles where possible instead of accessing the window structure.

parent c5bf4976
...@@ -57,11 +57,8 @@ static const WCHAR imm32W[] = { 'i','m','m','3','2','\0' }; ...@@ -57,11 +57,8 @@ static const WCHAR imm32W[] = { 'i','m','m','3','2','\0' };
static void DEFWND_HandleWindowPosChanged( HWND hwnd, const WINDOWPOS *winpos ) static void DEFWND_HandleWindowPosChanged( HWND hwnd, const WINDOWPOS *winpos )
{ {
RECT rect; RECT rect;
WND *wndPtr = WIN_GetPtr( hwnd );
rect = wndPtr->rectClient;
WIN_ReleasePtr( wndPtr );
WIN_GetRectangles( hwnd, COORDS_PARENT, NULL, &rect );
if (!(winpos->flags & SWP_NOCLIENTMOVE)) if (!(winpos->flags & SWP_NOCLIENTMOVE))
SendMessageW( hwnd, WM_MOVE, 0, MAKELONG(rect.left, rect.top)); SendMessageW( hwnd, WM_MOVE, 0, MAKELONG(rect.left, rect.top));
......
...@@ -477,19 +477,13 @@ LRESULT NC_HandleNCCalcSize( HWND hwnd, RECT *winRect ) ...@@ -477,19 +477,13 @@ LRESULT NC_HandleNCCalcSize( HWND hwnd, RECT *winRect )
* *
* Get the 'inside' rectangle of a window, i.e. the whole window rectangle * Get the 'inside' rectangle of a window, i.e. the whole window rectangle
* but without the borders (if any). * but without the borders (if any).
* The rectangle is in window coordinates (for drawing with GetWindowDC()).
*/ */
static void NC_GetInsideRect( HWND hwnd, RECT *rect, DWORD style, DWORD ex_style ) static void NC_GetInsideRect( HWND hwnd, enum coords_relative relative, RECT *rect,
DWORD style, DWORD ex_style )
{ {
WND *wndPtr = WIN_GetPtr( hwnd ); WIN_GetRectangles( hwnd, relative, rect, NULL );
if (!wndPtr || wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP) return;
rect->top = rect->left = 0; if (style & WS_ICONIC) return;
rect->right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
rect->bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
if (style & WS_ICONIC) goto END;
/* Remove frame from rectangle */ /* Remove frame from rectangle */
if (HAS_THICKFRAME( style, ex_style )) if (HAS_THICKFRAME( style, ex_style ))
...@@ -514,9 +508,6 @@ static void NC_GetInsideRect( HWND hwnd, RECT *rect, DWORD style, DWORD ex_style ...@@ -514,9 +508,6 @@ static void NC_GetInsideRect( HWND hwnd, RECT *rect, DWORD style, DWORD ex_style
if (ex_style & WS_EX_STATICEDGE) if (ex_style & WS_EX_STATICEDGE)
InflateRect (rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER)); InflateRect (rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
} }
END:
WIN_ReleasePtr( wndPtr );
} }
...@@ -708,7 +699,7 @@ BOOL NC_DrawSysButton (HWND hwnd, HDC hdc, BOOL down) ...@@ -708,7 +699,7 @@ BOOL NC_DrawSysButton (HWND hwnd, HDC hdc, BOOL down)
DWORD style = GetWindowLongW( hwnd, GWL_STYLE ); DWORD style = GetWindowLongW( hwnd, GWL_STYLE );
DWORD ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE ); DWORD ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE );
NC_GetInsideRect( hwnd, &rect, style, ex_style ); NC_GetInsideRect( hwnd, COORDS_WINDOW, &rect, style, ex_style );
DrawIconEx (hdc, rect.left + 2, rect.top + 1, hIcon, DrawIconEx (hdc, rect.left + 2, rect.top + 1, hIcon,
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL); GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL);
...@@ -733,7 +724,7 @@ static void NC_DrawCloseButton (HWND hwnd, HDC hdc, BOOL down, BOOL bGrayed) ...@@ -733,7 +724,7 @@ static void NC_DrawCloseButton (HWND hwnd, HDC hdc, BOOL down, BOOL bGrayed)
DWORD style = GetWindowLongW( hwnd, GWL_STYLE ); DWORD style = GetWindowLongW( hwnd, GWL_STYLE );
DWORD ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE ); DWORD ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE );
NC_GetInsideRect( hwnd, &rect, style, ex_style ); NC_GetInsideRect( hwnd, COORDS_WINDOW, &rect, style, ex_style );
/* A tool window has a smaller Close button */ /* A tool window has a smaller Close button */
if (ex_style & WS_EX_TOOLWINDOW) if (ex_style & WS_EX_TOOLWINDOW)
...@@ -778,7 +769,7 @@ static void NC_DrawMaxButton(HWND hwnd,HDC hdc,BOOL down, BOOL bGrayed) ...@@ -778,7 +769,7 @@ static void NC_DrawMaxButton(HWND hwnd,HDC hdc,BOOL down, BOOL bGrayed)
flags = (style & WS_MAXIMIZE) ? DFCS_CAPTIONRESTORE : DFCS_CAPTIONMAX; flags = (style & WS_MAXIMIZE) ? DFCS_CAPTIONRESTORE : DFCS_CAPTIONMAX;
NC_GetInsideRect( hwnd, &rect, style, ex_style ); NC_GetInsideRect( hwnd, COORDS_WINDOW, &rect, style, ex_style );
if (style & WS_SYSMENU) if (style & WS_SYSMENU)
rect.right -= GetSystemMetrics(SM_CXSIZE); rect.right -= GetSystemMetrics(SM_CXSIZE);
rect.left = rect.right - GetSystemMetrics(SM_CXSIZE); rect.left = rect.right - GetSystemMetrics(SM_CXSIZE);
...@@ -806,7 +797,7 @@ static void NC_DrawMinButton(HWND hwnd,HDC hdc,BOOL down, BOOL bGrayed) ...@@ -806,7 +797,7 @@ static void NC_DrawMinButton(HWND hwnd,HDC hdc,BOOL down, BOOL bGrayed)
/* never draw minimize box when window has WS_EX_TOOLWINDOW style */ /* never draw minimize box when window has WS_EX_TOOLWINDOW style */
if (ex_style & WS_EX_TOOLWINDOW) return; if (ex_style & WS_EX_TOOLWINDOW) return;
NC_GetInsideRect( hwnd, &rect, style, ex_style ); NC_GetInsideRect( hwnd, COORDS_WINDOW, &rect, style, ex_style );
if (style & WS_SYSMENU) if (style & WS_SYSMENU)
rect.right -= GetSystemMetrics(SM_CXSIZE); rect.right -= GetSystemMetrics(SM_CXSIZE);
if (style & (WS_MAXIMIZEBOX|WS_MINIMIZEBOX)) if (style & (WS_MAXIMIZEBOX|WS_MINIMIZEBOX))
...@@ -994,7 +985,7 @@ static void NC_DoNCPaint( HWND hwnd, HRGN clip, BOOL suppress_menupaint ) ...@@ -994,7 +985,7 @@ static void NC_DoNCPaint( HWND hwnd, HRGN clip, BOOL suppress_menupaint )
DWORD dwStyle, dwExStyle; DWORD dwStyle, dwExStyle;
WORD flags; WORD flags;
HRGN hrgn; HRGN hrgn;
RECT rectClient, rectWindow; RECT rectClient;
int has_menu; int has_menu;
if (!(wndPtr = WIN_GetPtr( hwnd )) || wndPtr == WND_OTHER_PROCESS) return; if (!(wndPtr = WIN_GetPtr( hwnd )) || wndPtr == WND_OTHER_PROCESS) return;
...@@ -1002,7 +993,6 @@ static void NC_DoNCPaint( HWND hwnd, HRGN clip, BOOL suppress_menupaint ) ...@@ -1002,7 +993,6 @@ static void NC_DoNCPaint( HWND hwnd, HRGN clip, BOOL suppress_menupaint )
dwStyle = wndPtr->dwStyle; dwStyle = wndPtr->dwStyle;
dwExStyle = wndPtr->dwExStyle; dwExStyle = wndPtr->dwExStyle;
flags = wndPtr->flags; flags = wndPtr->flags;
rectWindow = wndPtr->rectWindow;
WIN_ReleasePtr( wndPtr ); WIN_ReleasePtr( wndPtr );
if ( dwStyle & WS_MINIMIZE || if ( dwStyle & WS_MINIMIZE ||
...@@ -1019,8 +1009,7 @@ static void NC_DoNCPaint( HWND hwnd, HRGN clip, BOOL suppress_menupaint ) ...@@ -1019,8 +1009,7 @@ static void NC_DoNCPaint( HWND hwnd, HRGN clip, BOOL suppress_menupaint )
Now, how is the "system" supposed to tell what happened? Now, how is the "system" supposed to tell what happened?
*/ */
GetClientRect( hwnd, &rectClient ); WIN_GetRectangles( hwnd, COORDS_SCREEN, NULL, &rectClient );
MapWindowPoints( hwnd, 0, (POINT *)&rectClient, 2 );
hrgn = CreateRectRgnIndirect( &rectClient ); hrgn = CreateRectRgnIndirect( &rectClient );
if (clip > (HRGN)1) if (clip > (HRGN)1)
...@@ -1035,9 +1024,7 @@ static void NC_DoNCPaint( HWND hwnd, HRGN clip, BOOL suppress_menupaint ) ...@@ -1035,9 +1024,7 @@ static void NC_DoNCPaint( HWND hwnd, HRGN clip, BOOL suppress_menupaint )
if (!hdc) return; if (!hdc) return;
rect.top = rect.left = 0; WIN_GetRectangles( hwnd, COORDS_WINDOW, &rect, NULL );
rect.right = rectWindow.right - rectWindow.left;
rect.bottom = rectWindow.bottom - rectWindow.top;
GetClipBox( hdc, &rectClip ); GetClipBox( hdc, &rectClip );
SelectObject( hdc, SYSCOLOR_GetPen(COLOR_WINDOWFRAME) ); SelectObject( hdc, SYSCOLOR_GetPen(COLOR_WINDOWFRAME) );
...@@ -1222,15 +1209,10 @@ void NC_GetSysPopupPos( HWND hwnd, RECT* rect ) ...@@ -1222,15 +1209,10 @@ void NC_GetSysPopupPos( HWND hwnd, RECT* rect )
{ {
DWORD style = GetWindowLongW( hwnd, GWL_STYLE ); DWORD style = GetWindowLongW( hwnd, GWL_STYLE );
DWORD ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE ); DWORD ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE );
WND *wndPtr = WIN_GetPtr( hwnd );
if (!wndPtr || wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP) return;
NC_GetInsideRect( hwnd, rect, style, ex_style ); NC_GetInsideRect( hwnd, COORDS_SCREEN, rect, style, ex_style );
OffsetRect( rect, wndPtr->rectWindow.left, wndPtr->rectWindow.top);
if (style & WS_CHILD) ClientToScreen( GetParent(hwnd), (POINT *)rect );
rect->right = rect->left + GetSystemMetrics(SM_CYCAPTION) - 1; rect->right = rect->left + GetSystemMetrics(SM_CYCAPTION) - 1;
rect->bottom = rect->top + GetSystemMetrics(SM_CYCAPTION) - 1; rect->bottom = rect->top + GetSystemMetrics(SM_CYCAPTION) - 1;
WIN_ReleasePtr( wndPtr );
} }
} }
...@@ -1633,7 +1615,6 @@ LRESULT NC_HandleSysCommand( HWND hwnd, WPARAM wParam, LPARAM lParam ) ...@@ -1633,7 +1615,6 @@ LRESULT NC_HandleSysCommand( HWND hwnd, WPARAM wParam, LPARAM lParam )
BOOL WINAPI GetTitleBarInfo(HWND hwnd, PTITLEBARINFO tbi) { BOOL WINAPI GetTitleBarInfo(HWND hwnd, PTITLEBARINFO tbi) {
DWORD dwStyle; DWORD dwStyle;
DWORD dwExStyle; DWORD dwExStyle;
RECT wndRect;
TRACE("(%p %p)\n", hwnd, tbi); TRACE("(%p %p)\n", hwnd, tbi);
...@@ -1649,13 +1630,7 @@ BOOL WINAPI GetTitleBarInfo(HWND hwnd, PTITLEBARINFO tbi) { ...@@ -1649,13 +1630,7 @@ BOOL WINAPI GetTitleBarInfo(HWND hwnd, PTITLEBARINFO tbi) {
} }
dwStyle = GetWindowLongW(hwnd, GWL_STYLE); dwStyle = GetWindowLongW(hwnd, GWL_STYLE);
dwExStyle = GetWindowLongW(hwnd, GWL_EXSTYLE); dwExStyle = GetWindowLongW(hwnd, GWL_EXSTYLE);
NC_GetInsideRect(hwnd, &tbi->rcTitleBar, dwStyle, dwExStyle); NC_GetInsideRect(hwnd, COORDS_SCREEN, &tbi->rcTitleBar, dwStyle, dwExStyle);
GetWindowRect(hwnd, &wndRect);
tbi->rcTitleBar.top += wndRect.top;
tbi->rcTitleBar.left += wndRect.left;
tbi->rcTitleBar.right += wndRect.left;
tbi->rcTitleBar.bottom = tbi->rcTitleBar.top; tbi->rcTitleBar.bottom = tbi->rcTitleBar.top;
if(dwExStyle & WS_EX_TOOLWINDOW) if(dwExStyle & WS_EX_TOOLWINDOW)
......
...@@ -396,23 +396,18 @@ static void make_dc_dirty( struct dce *dce ) ...@@ -396,23 +396,18 @@ static void make_dc_dirty( struct dce *dce )
* rectangle. In addition, pWnd->parent DCEs may need to be updated if * rectangle. In addition, pWnd->parent DCEs may need to be updated if
* DCX_CLIPCHILDREN flag is set. * DCX_CLIPCHILDREN flag is set.
*/ */
void invalidate_dce( HWND hwnd, const RECT *rect ) void invalidate_dce( HWND hwnd, const RECT *extra_rect )
{ {
RECT window_rect, extra_rect; RECT window_rect;
struct dce *dce; struct dce *dce;
HWND hwndScope = GetAncestor( hwnd, GA_PARENT ); HWND hwndScope = GetAncestor( hwnd, GA_PARENT );
if (!hwndScope) return; if (!hwndScope) return;
GetWindowRect( hwnd, &window_rect ); GetWindowRect( hwnd, &window_rect );
if (rect)
{
extra_rect = *rect;
MapWindowPoints( hwndScope, 0, (POINT *)&extra_rect, 2 );
}
TRACE("%p scope hwnd = %p %s (%s)\n", TRACE("%p scope hwnd = %p %s (%s)\n",
hwnd, hwndScope, wine_dbgstr_rect(&window_rect), wine_dbgstr_rect(rect) ); hwnd, hwndScope, wine_dbgstr_rect(&window_rect), wine_dbgstr_rect(extra_rect) );
/* walk all DCEs and fixup non-empty entries */ /* walk all DCEs and fixup non-empty entries */
...@@ -439,7 +434,7 @@ void invalidate_dce( HWND hwnd, const RECT *rect ) ...@@ -439,7 +434,7 @@ void invalidate_dce( HWND hwnd, const RECT *rect )
RECT dce_rect, tmp; RECT dce_rect, tmp;
GetWindowRect( dce->hwnd, &dce_rect ); GetWindowRect( dce->hwnd, &dce_rect );
if (IntersectRect( &tmp, &dce_rect, &window_rect ) || if (IntersectRect( &tmp, &dce_rect, &window_rect ) ||
(rect && IntersectRect( &tmp, &dce_rect, &extra_rect ))) (extra_rect && IntersectRect( &tmp, &dce_rect, extra_rect )))
make_dc_dirty( dce ); make_dc_dirty( dce );
} }
} }
......
...@@ -223,23 +223,26 @@ static BOOL SCROLL_GetScrollBarRect( HWND hwnd, INT nBar, RECT *lprect, ...@@ -223,23 +223,26 @@ static BOOL SCROLL_GetScrollBarRect( HWND hwnd, INT nBar, RECT *lprect,
switch(nBar) switch(nBar)
{ {
case SB_HORZ: case SB_HORZ:
lprect->left = wndPtr->rectClient.left - wndPtr->rectWindow.left; WIN_GetRectangles( hwnd, COORDS_WINDOW, NULL, lprect );
lprect->top = wndPtr->rectClient.bottom - wndPtr->rectWindow.top; lprect->top = lprect->bottom;
lprect->right = wndPtr->rectClient.right - wndPtr->rectWindow.left; lprect->bottom += GetSystemMetrics(SM_CYHSCROLL);
lprect->bottom = lprect->top + GetSystemMetrics(SM_CYHSCROLL);
if(wndPtr->dwStyle & WS_VSCROLL) if(wndPtr->dwStyle & WS_VSCROLL)
lprect->right++; lprect->right++;
vertical = FALSE; vertical = FALSE;
break; break;
case SB_VERT: case SB_VERT:
WIN_GetRectangles( hwnd, COORDS_WINDOW, NULL, lprect );
if((wndPtr->dwExStyle & WS_EX_LEFTSCROLLBAR) != 0) if((wndPtr->dwExStyle & WS_EX_LEFTSCROLLBAR) != 0)
lprect->left = wndPtr->rectClient.left - wndPtr->rectWindow.left - GetSystemMetrics(SM_CXVSCROLL); {
lprect->right = lprect->left;
lprect->left -= GetSystemMetrics(SM_CXVSCROLL);
}
else else
lprect->left = wndPtr->rectClient.right - wndPtr->rectWindow.left; {
lprect->top = wndPtr->rectClient.top - wndPtr->rectWindow.top; lprect->left = lprect->right;
lprect->right = lprect->left + GetSystemMetrics(SM_CXVSCROLL); lprect->right += GetSystemMetrics(SM_CXVSCROLL);
lprect->bottom = wndPtr->rectClient.bottom - wndPtr->rectWindow.top; }
if(wndPtr->dwStyle & WS_HSCROLL) if(wndPtr->dwStyle & WS_HSCROLL)
lprect->bottom++; lprect->bottom++;
vertical = TRUE; vertical = TRUE;
...@@ -1095,14 +1098,11 @@ void SCROLL_TrackScrollBar( HWND hwnd, INT scrollbar, POINT pt ) ...@@ -1095,14 +1098,11 @@ void SCROLL_TrackScrollBar( HWND hwnd, INT scrollbar, POINT pt )
if (scrollbar != SB_CTL) if (scrollbar != SB_CTL)
{ {
WND *wndPtr = WIN_GetPtr( hwnd ); RECT rect;
if (!wndPtr || wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP) return; WIN_GetRectangles( hwnd, COORDS_CLIENT, &rect, NULL );
xoffset = wndPtr->rectClient.left - wndPtr->rectWindow.left;
yoffset = wndPtr->rectClient.top - wndPtr->rectWindow.top;
WIN_ReleasePtr( wndPtr );
ScreenToClient( hwnd, &pt ); ScreenToClient( hwnd, &pt );
pt.x += xoffset; pt.x -= rect.left;
pt.y += yoffset; pt.y -= rect.top;
} }
SCROLL_HandleScrollEvent( hwnd, scrollbar, WM_LBUTTONDOWN, pt ); SCROLL_HandleScrollEvent( hwnd, scrollbar, WM_LBUTTONDOWN, pt );
......
...@@ -1386,22 +1386,17 @@ HWND WIN_CreateWindowEx( CREATESTRUCTW *cs, LPCWSTR className, HINSTANCE module, ...@@ -1386,22 +1386,17 @@ HWND WIN_CreateWindowEx( CREATESTRUCTW *cs, LPCWSTR className, HINSTANCE module,
/* send WM_NCCALCSIZE */ /* send WM_NCCALCSIZE */
if ((wndPtr = WIN_GetPtr(hwnd))) if (WIN_GetRectangles( hwnd, COORDS_PARENT, &rect, NULL ))
{ {
/* yes, even if the CBT hook was called with HWND_TOP */ /* yes, even if the CBT hook was called with HWND_TOP */
POINT pt; HWND insert_after = (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD) ? HWND_BOTTOM : HWND_TOP;
HWND insert_after = (wndPtr->dwStyle & WS_CHILD) ? HWND_BOTTOM : HWND_TOP; RECT client_rect = rect;
RECT window_rect = wndPtr->rectWindow;
RECT client_rect = window_rect;
WIN_ReleasePtr( wndPtr );
/* the rectangle is in screen coords for WM_NCCALCSIZE when wparam is FALSE */ /* the rectangle is in screen coords for WM_NCCALCSIZE when wparam is FALSE */
pt.x = pt.y = 0; MapWindowPoints( parent, 0, (POINT *)&client_rect, 2 );
MapWindowPoints( parent, 0, &pt, 1 );
OffsetRect( &client_rect, pt.x, pt.y );
SendMessageW( hwnd, WM_NCCALCSIZE, FALSE, (LPARAM)&client_rect ); SendMessageW( hwnd, WM_NCCALCSIZE, FALSE, (LPARAM)&client_rect );
OffsetRect( &client_rect, -pt.x, -pt.y ); MapWindowPoints( 0, parent, (POINT *)&client_rect, 2 );
set_window_pos( hwnd, insert_after, SWP_NOACTIVATE, &window_rect, &client_rect, NULL ); set_window_pos( hwnd, insert_after, SWP_NOACTIVATE, &rect, &client_rect, NULL );
} }
else return 0; else return 0;
...@@ -1425,8 +1420,8 @@ HWND WIN_CreateWindowEx( CREATESTRUCTW *cs, LPCWSTR className, HINSTANCE module, ...@@ -1425,8 +1420,8 @@ HWND WIN_CreateWindowEx( CREATESTRUCTW *cs, LPCWSTR className, HINSTANCE module,
wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP) return 0; wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP) return 0;
if (!(wndPtr->flags & WIN_NEED_SIZE)) if (!(wndPtr->flags & WIN_NEED_SIZE))
{ {
rect = wndPtr->rectClient;
WIN_ReleasePtr( wndPtr ); WIN_ReleasePtr( wndPtr );
WIN_GetRectangles( hwnd, COORDS_PARENT, NULL, &rect );
SendMessageW( hwnd, WM_SIZE, SIZE_RESTORED, SendMessageW( hwnd, WM_SIZE, SIZE_RESTORED,
MAKELONG(rect.right-rect.left, rect.bottom-rect.top)); MAKELONG(rect.right-rect.left, rect.bottom-rect.top));
SendMessageW( hwnd, WM_MOVE, 0, MAKELONG( rect.left, rect.top ) ); SendMessageW( hwnd, WM_MOVE, 0, MAKELONG( rect.left, rect.top ) );
......
...@@ -771,16 +771,14 @@ static POINT WINPOS_FindIconPos( HWND hwnd, POINT pt ) ...@@ -771,16 +771,14 @@ static POINT WINPOS_FindIconPos( HWND hwnd, POINT pt )
tmp = CreateRectRgn( 0, 0, 0, 0 ); tmp = CreateRectRgn( 0, 0, 0, 0 );
for (child = GetWindow( parent, GW_HWNDFIRST ); child; child = GetWindow( child, GW_HWNDNEXT )) for (child = GetWindow( parent, GW_HWNDFIRST ); child; child = GetWindow( child, GW_HWNDNEXT ))
{ {
WND *childPtr;
if (child == hwnd) continue; if (child == hwnd) continue;
if ((GetWindowLongW( child, GWL_STYLE ) & (WS_VISIBLE|WS_MINIMIZE)) != (WS_VISIBLE|WS_MINIMIZE)) if ((GetWindowLongW( child, GWL_STYLE ) & (WS_VISIBLE|WS_MINIMIZE)) != (WS_VISIBLE|WS_MINIMIZE))
continue; continue;
if (!(childPtr = WIN_GetPtr( child )) || childPtr == WND_OTHER_PROCESS) if (WIN_GetRectangles( child, COORDS_PARENT, &rect, NULL ))
continue; {
SetRectRgn( tmp, childPtr->rectWindow.left, childPtr->rectWindow.top, SetRectRgn( tmp, rect.left, rect.top, rect.right, rect.bottom );
childPtr->rectWindow.right, childPtr->rectWindow.bottom ); CombineRgn( hrgn, hrgn, tmp, RGN_OR );
CombineRgn( hrgn, hrgn, tmp, RGN_OR ); }
WIN_ReleasePtr( childPtr );
} }
DeleteObject( tmp ); DeleteObject( tmp );
...@@ -1057,9 +1055,11 @@ static BOOL show_window( HWND hwnd, INT cmd ) ...@@ -1057,9 +1055,11 @@ static BOOL show_window( HWND hwnd, INT cmd )
{ {
/* should happen only in CreateWindowEx() */ /* should happen only in CreateWindowEx() */
int wParam = SIZE_RESTORED; int wParam = SIZE_RESTORED;
RECT client = wndPtr->rectClient; RECT client;
LPARAM lparam = MAKELONG( client.right - client.left, client.bottom - client.top ); LPARAM lparam;
WIN_GetRectangles( hwnd, COORDS_PARENT, NULL, &client );
lparam = MAKELONG( client.right - client.left, client.bottom - client.top );
wndPtr->flags &= ~WIN_NEED_SIZE; wndPtr->flags &= ~WIN_NEED_SIZE;
if (wndPtr->dwStyle & WS_MAXIMIZE) wParam = SIZE_MAXIMIZED; if (wndPtr->dwStyle & WS_MAXIMIZE) wParam = SIZE_MAXIMIZED;
else if (wndPtr->dwStyle & WS_MINIMIZE) else if (wndPtr->dwStyle & WS_MINIMIZE)
...@@ -1504,6 +1504,7 @@ static void dump_winpos_flags(UINT flags) ...@@ -1504,6 +1504,7 @@ static void dump_winpos_flags(UINT flags)
static BOOL SWP_DoWinPosChanging( WINDOWPOS* pWinpos, RECT* pNewWindowRect, RECT* pNewClientRect ) static BOOL SWP_DoWinPosChanging( WINDOWPOS* pWinpos, RECT* pNewWindowRect, RECT* pNewClientRect )
{ {
WND *wndPtr; WND *wndPtr;
RECT window_rect, client_rect;
/* Send WM_WINDOWPOSCHANGING message */ /* Send WM_WINDOWPOSCHANGING message */
...@@ -1515,9 +1516,9 @@ static BOOL SWP_DoWinPosChanging( WINDOWPOS* pWinpos, RECT* pNewWindowRect, RECT ...@@ -1515,9 +1516,9 @@ static BOOL SWP_DoWinPosChanging( WINDOWPOS* pWinpos, RECT* pNewWindowRect, RECT
/* Calculate new position and size */ /* Calculate new position and size */
*pNewWindowRect = wndPtr->rectWindow; WIN_GetRectangles( pWinpos->hwnd, COORDS_PARENT, &window_rect, &client_rect );
*pNewClientRect = (wndPtr->dwStyle & WS_MINIMIZE) ? wndPtr->rectWindow *pNewWindowRect = window_rect;
: wndPtr->rectClient; *pNewClientRect = (wndPtr->dwStyle & WS_MINIMIZE) ? window_rect : client_rect;
if (!(pWinpos->flags & SWP_NOSIZE)) if (!(pWinpos->flags & SWP_NOSIZE))
{ {
...@@ -1536,11 +1537,11 @@ static BOOL SWP_DoWinPosChanging( WINDOWPOS* pWinpos, RECT* pNewWindowRect, RECT ...@@ -1536,11 +1537,11 @@ static BOOL SWP_DoWinPosChanging( WINDOWPOS* pWinpos, RECT* pNewWindowRect, RECT
{ {
pNewWindowRect->left = pWinpos->x; pNewWindowRect->left = pWinpos->x;
pNewWindowRect->top = pWinpos->y; pNewWindowRect->top = pWinpos->y;
pNewWindowRect->right += pWinpos->x - wndPtr->rectWindow.left; pNewWindowRect->right += pWinpos->x - window_rect.left;
pNewWindowRect->bottom += pWinpos->y - wndPtr->rectWindow.top; pNewWindowRect->bottom += pWinpos->y - window_rect.top;
OffsetRect( pNewClientRect, pWinpos->x - wndPtr->rectWindow.left, OffsetRect( pNewClientRect, pWinpos->x - window_rect.left,
pWinpos->y - wndPtr->rectWindow.top ); pWinpos->y - window_rect.top );
} }
pWinpos->flags |= SWP_NOCLIENTMOVE | SWP_NOCLIENTSIZE; pWinpos->flags |= SWP_NOCLIENTMOVE | SWP_NOCLIENTSIZE;
...@@ -1548,7 +1549,7 @@ static BOOL SWP_DoWinPosChanging( WINDOWPOS* pWinpos, RECT* pNewWindowRect, RECT ...@@ -1548,7 +1549,7 @@ static BOOL SWP_DoWinPosChanging( WINDOWPOS* pWinpos, RECT* pNewWindowRect, RECT
pWinpos->hwnd, pWinpos->hwndInsertAfter, pWinpos->x, pWinpos->y, pWinpos->hwnd, pWinpos->hwndInsertAfter, pWinpos->x, pWinpos->y,
pWinpos->cx, pWinpos->cy, pWinpos->flags ); pWinpos->cx, pWinpos->cy, pWinpos->flags );
TRACE( "current %s style %08x new %s\n", TRACE( "current %s style %08x new %s\n",
wine_dbgstr_rect( &wndPtr->rectWindow ), wndPtr->dwStyle, wine_dbgstr_rect( &window_rect ), wndPtr->dwStyle,
wine_dbgstr_rect( pNewWindowRect )); wine_dbgstr_rect( pNewWindowRect ));
WIN_ReleasePtr( wndPtr ); WIN_ReleasePtr( wndPtr );
...@@ -1706,9 +1707,9 @@ static UINT SWP_DoNCCalcSize( WINDOWPOS* pWinpos, const RECT* pNewWindowRect, RE ...@@ -1706,9 +1707,9 @@ static UINT SWP_DoNCCalcSize( WINDOWPOS* pWinpos, const RECT* pNewWindowRect, RE
RECT *validRects ) RECT *validRects )
{ {
UINT wvrFlags = 0; UINT wvrFlags = 0;
WND *wndPtr; RECT window_rect, client_rect;
if (!(wndPtr = WIN_GetPtr( pWinpos->hwnd )) || wndPtr == WND_OTHER_PROCESS) return 0; WIN_GetRectangles( pWinpos->hwnd, COORDS_PARENT, &window_rect, &client_rect );
/* Send WM_NCCALCSIZE message to get new client area */ /* Send WM_NCCALCSIZE message to get new client area */
if( (pWinpos->flags & (SWP_FRAMECHANGED | SWP_NOSIZE)) != SWP_NOSIZE ) if( (pWinpos->flags & (SWP_FRAMECHANGED | SWP_NOSIZE)) != SWP_NOSIZE )
...@@ -1717,34 +1718,31 @@ static UINT SWP_DoNCCalcSize( WINDOWPOS* pWinpos, const RECT* pNewWindowRect, RE ...@@ -1717,34 +1718,31 @@ static UINT SWP_DoNCCalcSize( WINDOWPOS* pWinpos, const RECT* pNewWindowRect, RE
WINDOWPOS winposCopy; WINDOWPOS winposCopy;
params.rgrc[0] = *pNewWindowRect; params.rgrc[0] = *pNewWindowRect;
params.rgrc[1] = wndPtr->rectWindow; params.rgrc[1] = window_rect;
params.rgrc[2] = wndPtr->rectClient; params.rgrc[2] = client_rect;
params.lppos = &winposCopy; params.lppos = &winposCopy;
winposCopy = *pWinpos; winposCopy = *pWinpos;
WIN_ReleasePtr( wndPtr );
wvrFlags = SendMessageW( pWinpos->hwnd, WM_NCCALCSIZE, TRUE, (LPARAM)&params ); wvrFlags = SendMessageW( pWinpos->hwnd, WM_NCCALCSIZE, TRUE, (LPARAM)&params );
*pNewClientRect = params.rgrc[0]; *pNewClientRect = params.rgrc[0];
if (!(wndPtr = WIN_GetPtr( pWinpos->hwnd )) || wndPtr == WND_OTHER_PROCESS) return 0;
TRACE( "hwnd %p old win %s old client %s new win %s new client %s\n", pWinpos->hwnd, TRACE( "hwnd %p old win %s old client %s new win %s new client %s\n", pWinpos->hwnd,
wine_dbgstr_rect(&wndPtr->rectWindow), wine_dbgstr_rect(&wndPtr->rectClient), wine_dbgstr_rect(&window_rect), wine_dbgstr_rect(&client_rect),
wine_dbgstr_rect(pNewWindowRect), wine_dbgstr_rect(pNewClientRect) ); wine_dbgstr_rect(pNewWindowRect), wine_dbgstr_rect(pNewClientRect) );
if( pNewClientRect->left != wndPtr->rectClient.left || if( pNewClientRect->left != client_rect.left ||
pNewClientRect->top != wndPtr->rectClient.top ) pNewClientRect->top != client_rect.top )
pWinpos->flags &= ~SWP_NOCLIENTMOVE; pWinpos->flags &= ~SWP_NOCLIENTMOVE;
if( (pNewClientRect->right - pNewClientRect->left != if( (pNewClientRect->right - pNewClientRect->left !=
wndPtr->rectClient.right - wndPtr->rectClient.left)) client_rect.right - client_rect.left))
pWinpos->flags &= ~SWP_NOCLIENTSIZE; pWinpos->flags &= ~SWP_NOCLIENTSIZE;
else else
wvrFlags &= ~WVR_HREDRAW; wvrFlags &= ~WVR_HREDRAW;
if (pNewClientRect->bottom - pNewClientRect->top != if (pNewClientRect->bottom - pNewClientRect->top !=
wndPtr->rectClient.bottom - wndPtr->rectClient.top) client_rect.bottom - client_rect.top)
pWinpos->flags &= ~SWP_NOCLIENTSIZE; pWinpos->flags &= ~SWP_NOCLIENTSIZE;
else else
wvrFlags &= ~WVR_VREDRAW; wvrFlags &= ~WVR_VREDRAW;
...@@ -1755,8 +1753,8 @@ static UINT SWP_DoNCCalcSize( WINDOWPOS* pWinpos, const RECT* pNewWindowRect, RE ...@@ -1755,8 +1753,8 @@ static UINT SWP_DoNCCalcSize( WINDOWPOS* pWinpos, const RECT* pNewWindowRect, RE
else else
{ {
if (!(pWinpos->flags & SWP_NOMOVE) && if (!(pWinpos->flags & SWP_NOMOVE) &&
(pNewClientRect->left != wndPtr->rectClient.left || (pNewClientRect->left != client_rect.left ||
pNewClientRect->top != wndPtr->rectClient.top)) pNewClientRect->top != client_rect.top))
pWinpos->flags &= ~SWP_NOCLIENTMOVE; pWinpos->flags &= ~SWP_NOCLIENTMOVE;
} }
...@@ -1765,9 +1763,8 @@ static UINT SWP_DoNCCalcSize( WINDOWPOS* pWinpos, const RECT* pNewWindowRect, RE ...@@ -1765,9 +1763,8 @@ static UINT SWP_DoNCCalcSize( WINDOWPOS* pWinpos, const RECT* pNewWindowRect, RE
SetRectEmpty( &validRects[0] ); SetRectEmpty( &validRects[0] );
SetRectEmpty( &validRects[1] ); SetRectEmpty( &validRects[1] );
} }
else get_valid_rects( &wndPtr->rectClient, pNewClientRect, wvrFlags, validRects ); else get_valid_rects( &client_rect, pNewClientRect, wvrFlags, validRects );
WIN_ReleasePtr( wndPtr );
return wvrFlags; return wvrFlags;
} }
...@@ -1775,6 +1772,7 @@ static UINT SWP_DoNCCalcSize( WINDOWPOS* pWinpos, const RECT* pNewWindowRect, RE ...@@ -1775,6 +1772,7 @@ static UINT SWP_DoNCCalcSize( WINDOWPOS* pWinpos, const RECT* pNewWindowRect, RE
static BOOL fixup_flags( WINDOWPOS *winpos ) static BOOL fixup_flags( WINDOWPOS *winpos )
{ {
HWND parent; HWND parent;
RECT window_rect;
WND *wndPtr = WIN_GetPtr( winpos->hwnd ); WND *wndPtr = WIN_GetPtr( winpos->hwnd );
BOOL ret = TRUE; BOOL ret = TRUE;
...@@ -1806,11 +1804,12 @@ static BOOL fixup_flags( WINDOWPOS *winpos ) ...@@ -1806,11 +1804,12 @@ static BOOL fixup_flags( WINDOWPOS *winpos )
if (!(winpos->flags & SWP_SHOWWINDOW)) winpos->flags |= SWP_NOREDRAW; if (!(winpos->flags & SWP_SHOWWINDOW)) winpos->flags |= SWP_NOREDRAW;
} }
if ((wndPtr->rectWindow.right - wndPtr->rectWindow.left == winpos->cx) && WIN_GetRectangles( winpos->hwnd, COORDS_PARENT, &window_rect, NULL );
(wndPtr->rectWindow.bottom - wndPtr->rectWindow.top == winpos->cy)) if ((window_rect.right - window_rect.left == winpos->cx) &&
(window_rect.bottom - window_rect.top == winpos->cy))
winpos->flags |= SWP_NOSIZE; /* Already the right size */ winpos->flags |= SWP_NOSIZE; /* Already the right size */
if ((wndPtr->rectWindow.left == winpos->x) && (wndPtr->rectWindow.top == winpos->y)) if ((window_rect.left == winpos->x) && (window_rect.top == winpos->y))
winpos->flags |= SWP_NOMOVE; /* Already the right position */ winpos->flags |= SWP_NOMOVE; /* Already the right position */
if ((wndPtr->dwStyle & (WS_POPUP | WS_CHILD)) != WS_CHILD) if ((wndPtr->dwStyle & (WS_POPUP | WS_CHILD)) != WS_CHILD)
...@@ -1887,10 +1886,11 @@ BOOL set_window_pos( HWND hwnd, HWND insert_after, UINT swp_flags, ...@@ -1887,10 +1886,11 @@ BOOL set_window_pos( HWND hwnd, HWND insert_after, UINT swp_flags,
USER_Driver->pWindowPosChanging( hwnd, insert_after, swp_flags, USER_Driver->pWindowPosChanging( hwnd, insert_after, swp_flags,
window_rect, client_rect, &visible_rect ); window_rect, client_rect, &visible_rect );
WIN_GetRectangles( hwnd, COORDS_SCREEN, &old_window_rect, NULL );
if (!(win = WIN_GetPtr( hwnd ))) return FALSE; if (!(win = WIN_GetPtr( hwnd ))) return FALSE;
if (win == WND_DESKTOP || win == WND_OTHER_PROCESS) return FALSE; if (win == WND_DESKTOP || win == WND_OTHER_PROCESS) return FALSE;
old_window_rect = win->rectWindow;
SERVER_START_REQ( set_window_pos ) SERVER_START_REQ( set_window_pos )
{ {
req->handle = wine_server_user_handle( hwnd ); req->handle = wine_server_user_handle( hwnd );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment