Replace a number of calls to WIN_FindWndPtr by WIN_GetPtr.

This commit is contained in:
Alexandre Julliard 2005-01-20 20:07:42 +00:00
parent 97199823bf
commit 6382ffae2a
10 changed files with 113 additions and 97 deletions

View File

@ -311,11 +311,11 @@ static POPUPMENU *MENU_GetMenu(HMENU hMenu)
static HMENU get_win_sys_menu( HWND hwnd )
{
HMENU ret = 0;
WND *win = WIN_FindWndPtr( hwnd );
if (win)
WND *win = WIN_GetPtr( hwnd );
if (win && win != WND_OTHER_PROCESS)
{
ret = win->hSysMenu;
WIN_ReleaseWndPtr( win );
WIN_ReleasePtr( win );
}
return ret;
}
@ -3584,10 +3584,14 @@ BOOL WINAPI DestroyMenu( HMENU hMenu )
*/
HMENU WINAPI GetSystemMenu( HWND hWnd, BOOL bRevert )
{
WND *wndPtr = WIN_FindWndPtr( hWnd );
WND *wndPtr = WIN_GetPtr( hWnd );
HMENU retvalue = 0;
if (wndPtr)
if (wndPtr == WND_OTHER_PROCESS)
{
if (IsWindow( hWnd )) FIXME( "not supported on other process window %p\n", hWnd );
}
else if (wndPtr)
{
if( wndPtr->hSysMenu )
{
@ -3627,7 +3631,7 @@ HMENU WINAPI GetSystemMenu( HWND hWnd, BOOL bRevert )
if ( menu )
menu->hSysMenuOwner = wndPtr->hSysMenu;
}
WIN_ReleaseWndPtr(wndPtr);
WIN_ReleasePtr( wndPtr );
}
return bRevert ? 0 : retvalue;
}
@ -3638,13 +3642,13 @@ HMENU WINAPI GetSystemMenu( HWND hWnd, BOOL bRevert )
*/
BOOL WINAPI SetSystemMenu( HWND hwnd, HMENU hMenu )
{
WND *wndPtr = WIN_FindWndPtr(hwnd);
WND *wndPtr = WIN_GetPtr( hwnd );
if (wndPtr)
if (wndPtr && wndPtr != WND_OTHER_PROCESS)
{
if (wndPtr->hSysMenu) DestroyMenu( wndPtr->hSysMenu );
wndPtr->hSysMenu = MENU_GetSysMenu( hwnd, hMenu );
WIN_ReleaseWndPtr(wndPtr);
WIN_ReleasePtr( wndPtr );
return TRUE;
}
return FALSE;

View File

@ -151,9 +151,9 @@ LPSCROLLINFO info /* [in] The SCROLLINFO struct to be tested */)
static SCROLLBAR_INFO *SCROLL_GetScrollBarInfo( HWND hwnd, INT nBar )
{
SCROLLBAR_INFO *infoPtr;
WND *wndPtr = WIN_FindWndPtr( hwnd );
WND *wndPtr = WIN_GetPtr( hwnd );
if (!wndPtr) return NULL;
if (!wndPtr || wndPtr == WND_OTHER_PROCESS) return NULL;
switch(nBar)
{
case SB_HORZ: infoPtr = (SCROLLBAR_INFO *)wndPtr->pHScroll; break;
@ -175,7 +175,7 @@ static SCROLLBAR_INFO *SCROLL_GetScrollBarInfo( HWND hwnd, INT nBar )
else wndPtr->pVScroll = infoPtr;
}
}
WIN_ReleaseWndPtr( wndPtr );
WIN_ReleasePtr( wndPtr );
return infoPtr;
}
@ -197,7 +197,9 @@ static BOOL SCROLL_GetScrollBarRect( HWND hwnd, INT nBar, RECT *lprect,
{
INT pixels;
BOOL vertical;
WND *wndPtr = WIN_FindWndPtr( hwnd );
WND *wndPtr = WIN_GetPtr( hwnd );
if (!wndPtr || wndPtr == WND_OTHER_PROCESS) return FALSE;
switch(nBar)
{
@ -236,7 +238,7 @@ static BOOL SCROLL_GetScrollBarRect( HWND hwnd, INT nBar, RECT *lprect,
break;
default:
WIN_ReleaseWndPtr(wndPtr);
WIN_ReleasePtr( wndPtr );
return FALSE;
}
@ -281,7 +283,7 @@ static BOOL SCROLL_GetScrollBarRect( HWND hwnd, INT nBar, RECT *lprect,
+ MulDiv(pixels, (info->curVal-info->minVal),(max - info->minVal));
}
}
WIN_ReleaseWndPtr(wndPtr);
WIN_ReleasePtr( wndPtr );
return vertical;
}
@ -660,22 +662,22 @@ void SCROLL_DrawScrollBar( HWND hwnd, HDC hdc, INT nBar,
INT arrowSize, thumbSize, thumbPos;
RECT rect;
BOOL vertical;
WND *wndPtr = WIN_FindWndPtr( hwnd );
SCROLLBAR_INFO *infoPtr = SCROLL_GetScrollBarInfo( hwnd, nBar );
BOOL Save_SCROLL_MovingThumb = SCROLL_MovingThumb;
DWORD style = GetWindowLongW( hwnd, GWL_STYLE );
if (!wndPtr || !infoPtr ||
((nBar == SB_VERT) && !(wndPtr->dwStyle & WS_VSCROLL)) ||
((nBar == SB_HORZ) && !(wndPtr->dwStyle & WS_HSCROLL))) goto END;
if (!WIN_IsWindowDrawable( hwnd, FALSE )) goto END;
hwnd = wndPtr->hwndSelf; /* make it a full handle */
if (!(hwnd = WIN_GetFullHandle( hwnd ))) return;
if (!infoPtr ||
((nBar == SB_VERT) && !(style & WS_VSCROLL)) ||
((nBar == SB_HORZ) && !(style & WS_HSCROLL))) return;
if (!WIN_IsWindowDrawable( hwnd, FALSE )) return;
vertical = SCROLL_GetScrollBarRect( hwnd, nBar, &rect,
&arrowSize, &thumbSize, &thumbPos );
/* do not draw if the scrollbar rectangle is empty */
if(IsRectEmpty(&rect))
goto END;
if(IsRectEmpty(&rect)) return;
if (Save_SCROLL_MovingThumb &&
(SCROLL_TrackingWin == hwnd) &&
@ -715,9 +717,6 @@ void SCROLL_DrawScrollBar( HWND hwnd, HDC hdc, INT nBar,
SetCaretPos(rect.top+1, thumbPos+1);
}
}
END:
WIN_ReleaseWndPtr(wndPtr);
}
/***********************************************************************

View File

@ -1062,7 +1062,7 @@ static void EVENT_DropFromOffiX( HWND hWnd, XClientMessageEvent *event )
(unsigned int*)&aux_long);
wine_tsx11_unlock();
pWnd = WIN_FindWndPtr(hWnd);
pWnd = WIN_GetPtr(hWnd);
/* find out drop point and drop window */
if( x < 0 || y < 0 ||
@ -1089,7 +1089,7 @@ static void EVENT_DropFromOffiX( HWND hWnd, XClientMessageEvent *event )
bAccept = FALSE;
}
}
WIN_ReleaseWndPtr(pWnd);
WIN_ReleasePtr(pWnd);
if (!bAccept) return;
@ -1128,7 +1128,7 @@ static void EVENT_DropFromOffiX( HWND hWnd, XClientMessageEvent *event )
if( lpDrop )
{
WND *pDropWnd = WIN_FindWndPtr( hScope );
WND *pDropWnd = WIN_GetPtr( hScope );
lpDrop->pFiles = sizeof(DROPFILES);
lpDrop->pt.x = x;
lpDrop->pt.y = y;
@ -1138,7 +1138,7 @@ static void EVENT_DropFromOffiX( HWND hWnd, XClientMessageEvent *event )
x > (pDropWnd->rectClient.right - pDropWnd->rectWindow.left) ||
y > (pDropWnd->rectClient.bottom - pDropWnd->rectWindow.top) );
lpDrop->fWide = FALSE;
WIN_ReleaseWndPtr(pDropWnd);
WIN_ReleasePtr(pDropWnd);
p_drop = (char *)(lpDrop + 1);
p = p_data;
while(*p)
@ -1226,7 +1226,7 @@ static void EVENT_DropURLs( HWND hWnd, XClientMessageEvent *event )
lpDrop = (DROPFILES *) GlobalLock( hDrop );
if( lpDrop ) {
WND *pDropWnd = WIN_FindWndPtr( hWnd );
WND *pDropWnd = WIN_GetPtr( hWnd );
lpDrop->pFiles = sizeof(DROPFILES);
lpDrop->pt.x = (INT)x;
lpDrop->pt.y = (INT)y;
@ -1237,7 +1237,7 @@ static void EVENT_DropURLs( HWND hWnd, XClientMessageEvent *event )
y > (pDropWnd->rectClient.bottom - pDropWnd->rectWindow.top) );
lpDrop->fWide = FALSE;
p_drop = (char*)(lpDrop + 1);
WIN_ReleaseWndPtr(pDropWnd);
WIN_ReleasePtr(pDropWnd);
}
/* create message content */

View File

@ -1133,22 +1133,20 @@ BOOL X11DRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
/* Send the size messages */
if (!(wndPtr = WIN_FindWndPtr(hwnd))) return FALSE;
if (!(wndPtr = WIN_GetPtr(hwnd)) || wndPtr == WND_OTHER_PROCESS) return FALSE;
if (!(wndPtr->flags & WIN_NEED_SIZE))
{
RECT rect = wndPtr->rectClient;
WIN_ReleasePtr( wndPtr );
/* send it anyway */
if (((wndPtr->rectClient.right-wndPtr->rectClient.left) <0)
||((wndPtr->rectClient.bottom-wndPtr->rectClient.top)<0))
if (((rect.right-rect.left) <0) ||((rect.bottom-rect.top)<0))
WARN("sending bogus WM_SIZE message 0x%08lx\n",
MAKELONG(wndPtr->rectClient.right-wndPtr->rectClient.left,
wndPtr->rectClient.bottom-wndPtr->rectClient.top));
MAKELONG(rect.right-rect.left, rect.bottom-rect.top));
SendMessageW( hwnd, WM_SIZE, SIZE_RESTORED,
MAKELONG(wndPtr->rectClient.right-wndPtr->rectClient.left,
wndPtr->rectClient.bottom-wndPtr->rectClient.top));
SendMessageW( hwnd, WM_MOVE, 0,
MAKELONG( wndPtr->rectClient.left, wndPtr->rectClient.top ) );
MAKELONG(rect.right-rect.left, rect.bottom-rect.top));
SendMessageW( hwnd, WM_MOVE, 0, MAKELONG( rect.left, rect.top ) );
}
WIN_ReleaseWndPtr( wndPtr );
else WIN_ReleasePtr( wndPtr );
/* Show the window, maximizing or minimizing if needed */

View File

@ -926,16 +926,17 @@ static POINT WINPOS_FindIconPos( WND* wndPtr, POINT pt )
{
if (list[i] == wndPtr->hwndSelf) continue;
if (!IsIconic( list[i] )) continue;
if (!(childPtr = WIN_FindWndPtr( list[i] ))) continue;
if (!(childPtr = WIN_GetPtr( list[i] )) || childPtr == WND_OTHER_PROCESS)
continue;
if ((childPtr->rectWindow.left < x + xspacing) &&
(childPtr->rectWindow.right >= x) &&
(childPtr->rectWindow.top <= y) &&
(childPtr->rectWindow.bottom > y - yspacing))
{
WIN_ReleaseWndPtr( childPtr );
WIN_ReleasePtr( childPtr );
break; /* There's a window in there */
}
WIN_ReleaseWndPtr( childPtr );
WIN_ReleasePtr( childPtr );
}
if (list[i])
{

View File

@ -996,15 +996,15 @@ static HWND DIALOG_FindMsgDestination( HWND hwndDlg )
HWND hParent = GetParent(hwndDlg);
if (!hParent) break;
pParent = WIN_FindWndPtr(hParent);
if (!pParent) break;
pParent = WIN_GetPtr(hParent);
if (!pParent || pParent == WND_OTHER_PROCESS) break;
if (!(pParent->flags & WIN_ISDIALOG))
{
WIN_ReleaseWndPtr(pParent);
WIN_ReleasePtr(pParent);
break;
}
WIN_ReleaseWndPtr(pParent);
WIN_ReleasePtr(pParent);
hwndDlg = hParent;
}

View File

@ -1655,13 +1655,14 @@ void WINAPI CalcChildScroll( HWND hwnd, INT scroll )
}
if (style & WS_VISIBLE)
{
WND *pWnd = WIN_FindWndPtr( list[i] );
UnionRect( &childRect, &pWnd->rectWindow, &childRect );
WIN_ReleaseWndPtr( pWnd );
RECT rect;
GetWindowRect( list[i], &rect );
UnionRect( &childRect, &rect, &childRect );
}
}
HeapFree( GetProcessHeap(), 0, list );
}
MapWindowPoints( 0, hwnd, (POINT *)&childRect, 2 );
UnionRect( &childRect, &clientRect, &childRect );
/* set common info values */

View File

@ -428,7 +428,9 @@ LONG NC_HandleNCCalcSize( HWND hwnd, RECT *winRect )
*/
static void NC_GetInsideRect( HWND hwnd, RECT *rect )
{
WND * wndPtr = WIN_FindWndPtr( hwnd );
WND *wndPtr = WIN_GetPtr( hwnd );
if (!wndPtr || wndPtr == WND_OTHER_PROCESS) return;
rect->top = rect->left = 0;
rect->right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
@ -462,8 +464,7 @@ static void NC_GetInsideRect( HWND hwnd, RECT *rect )
}
END:
WIN_ReleaseWndPtr(wndPtr);
return;
WIN_ReleasePtr( wndPtr );
}
@ -628,13 +629,12 @@ static LONG NC_DoNCHitTest (WND *wndPtr, POINT pt )
LONG NC_HandleNCHitTest (HWND hwnd , POINT pt)
{
LONG retvalue;
WND *wndPtr = WIN_FindWndPtr (hwnd);
WND *wndPtr = WIN_GetPtr( hwnd );
if (!wndPtr)
return HTERROR;
if (!wndPtr || wndPtr == WND_OTHER_PROCESS) return HTERROR;
retvalue = NC_DoNCHitTest (wndPtr, pt);
WIN_ReleaseWndPtr(wndPtr);
WIN_ReleasePtr( wndPtr );
return retvalue;
}
@ -1092,24 +1092,24 @@ LONG NC_HandleNCPaint( HWND hwnd , HRGN clip)
*/
LONG NC_HandleNCActivate( HWND hwnd, WPARAM wParam )
{
WND* wndPtr = WIN_FindWndPtr( hwnd );
WND* wndPtr = WIN_GetPtr( hwnd );
if (!wndPtr || wndPtr == WND_OTHER_PROCESS) return FALSE;
/* Lotus Notes draws menu descriptions in the caption of its main
* window. When it wants to restore original "system" view, it just
* sends WM_NCACTIVATE message to itself. Any optimizations here in
* attempt to minimize redrawings lead to a not restored caption.
*/
if (wndPtr)
{
if (wParam) wndPtr->flags |= WIN_NCACTIVATED;
else wndPtr->flags &= ~WIN_NCACTIVATED;
WIN_ReleaseWndPtr(wndPtr);
if (wParam) wndPtr->flags |= WIN_NCACTIVATED;
else wndPtr->flags &= ~WIN_NCACTIVATED;
WIN_ReleasePtr( wndPtr );
if (IsIconic(hwnd))
WINPOS_RedrawIconTitle( hwnd );
else
NC_DoNCPaint( hwnd, (HRGN)1, FALSE );
if (IsIconic(hwnd))
WINPOS_RedrawIconTitle( hwnd );
else
NC_DoNCPaint( hwnd, (HRGN)1, FALSE );
}
return TRUE;
}
@ -1173,8 +1173,8 @@ void NC_GetSysPopupPos( HWND hwnd, RECT* rect )
if (IsIconic(hwnd)) GetWindowRect( hwnd, rect );
else
{
WND *wndPtr = WIN_FindWndPtr( hwnd );
if (!wndPtr) return;
WND *wndPtr = WIN_GetPtr( hwnd );
if (!wndPtr || wndPtr == WND_OTHER_PROCESS) return;
NC_GetInsideRect( hwnd, rect );
OffsetRect( rect, wndPtr->rectWindow.left, wndPtr->rectWindow.top);
@ -1182,7 +1182,7 @@ void NC_GetSysPopupPos( HWND hwnd, RECT* rect )
ClientToScreen( GetParent(hwnd), (POINT *)rect );
rect->right = rect->left + GetSystemMetrics(SM_CYCAPTION) - 1;
rect->bottom = rect->top + GetSystemMetrics(SM_CYCAPTION) - 1;
WIN_ReleaseWndPtr( wndPtr );
WIN_ReleasePtr( wndPtr );
}
}

View File

@ -1751,9 +1751,9 @@ BOOL WINAPI IsWindowUnicode( HWND hwnd )
WND * wndPtr;
BOOL retvalue;
if (!(wndPtr = WIN_FindWndPtr(hwnd))) return FALSE;
if (!(wndPtr = WIN_GetPtr(hwnd)) || wndPtr == WND_OTHER_PROCESS) return FALSE;
retvalue = (WINPROC_GetProcType( wndPtr->winproc ) == WIN_PROC_32W);
WIN_ReleaseWndPtr(wndPtr);
WIN_ReleasePtr( wndPtr );
return retvalue;
}
@ -3104,10 +3104,15 @@ BOOL WINAPI FlashWindowEx( PFLASHWINFO pfwi )
DWORD WINAPI GetWindowContextHelpId( HWND hwnd )
{
DWORD retval;
WND *wnd = WIN_FindWndPtr( hwnd );
WND *wnd = WIN_GetPtr( hwnd );
if (!wnd) return 0;
if (wnd == WND_OTHER_PROCESS)
{
if (IsWindow( hwnd )) FIXME( "not supported on other process window %p\n", hwnd );
return 0;
}
retval = wnd->helpContext;
WIN_ReleaseWndPtr(wnd);
WIN_ReleasePtr( wnd );
return retval;
}
@ -3117,10 +3122,15 @@ DWORD WINAPI GetWindowContextHelpId( HWND hwnd )
*/
BOOL WINAPI SetWindowContextHelpId( HWND hwnd, DWORD id )
{
WND *wnd = WIN_FindWndPtr( hwnd );
WND *wnd = WIN_GetPtr( hwnd );
if (!wnd) return FALSE;
if (wnd == WND_OTHER_PROCESS)
{
if (IsWindow( hwnd )) FIXME( "not supported on other process window %p\n", hwnd );
return 0;
}
wnd->helpContext = id;
WIN_ReleaseWndPtr(wnd);
WIN_ReleasePtr( wnd );
return TRUE;
}

View File

@ -630,10 +630,9 @@ BOOL WINAPI MoveWindow( HWND hwnd, INT x, INT y, INT cx, INT cy,
/***********************************************************************
* WINPOS_InitInternalPos
*/
static LPINTERNALPOS WINPOS_InitInternalPos( WND* wnd, POINT pt, const RECT *restoreRect )
static LPINTERNALPOS WINPOS_InitInternalPos( WND* wnd )
{
LPINTERNALPOS lpPos = (LPINTERNALPOS) GetPropA( wnd->hwndSelf,
atomInternalPos );
LPINTERNALPOS lpPos = GetPropA( wnd->hwndSelf, atomInternalPos );
if( !lpPos )
{
/* this happens when the window is minimized/maximized
@ -654,20 +653,20 @@ static LPINTERNALPOS WINPOS_InitInternalPos( WND* wnd, POINT pt, const RECT *res
if( wnd->dwStyle & WS_MINIMIZE )
{
lpPos->ptIconPos.x = pt.x;
lpPos->ptIconPos.y = pt.y;
lpPos->ptIconPos.x = wnd->rectWindow.left;
lpPos->ptIconPos.y = wnd->rectWindow.top;
}
else if( wnd->dwStyle & WS_MAXIMIZE )
{
lpPos->ptMaxPos.x = pt.x;
lpPos->ptMaxPos.y = pt.y;
lpPos->ptMaxPos.x = wnd->rectWindow.left;
lpPos->ptMaxPos.y = wnd->rectWindow.top;
}
else if( restoreRect )
else
{
lpPos->rectNormal.left = restoreRect->left;
lpPos->rectNormal.top = restoreRect->top;
lpPos->rectNormal.right = restoreRect->right;
lpPos->rectNormal.bottom = restoreRect->bottom;
lpPos->rectNormal.left = wnd->rectWindow.left;
lpPos->rectNormal.top = wnd->rectWindow.top;
lpPos->rectNormal.right = wnd->rectWindow.right;
lpPos->rectNormal.bottom = wnd->rectWindow.bottom;
}
return lpPos;
}
@ -891,12 +890,17 @@ UINT WINAPI GetInternalWindowPos( HWND hwnd, LPRECT rectWnd,
*/
BOOL WINAPI GetWindowPlacement( HWND hwnd, WINDOWPLACEMENT *wndpl )
{
WND *pWnd = WIN_FindWndPtr( hwnd );
WND *pWnd = WIN_GetPtr( hwnd );
LPINTERNALPOS lpPos;
if(!pWnd ) return FALSE;
if (!pWnd) return FALSE;
if (pWnd == WND_OTHER_PROCESS)
{
if (IsWindow( hwnd )) FIXME( "not supported on other process window %p\n", hwnd );
return FALSE;
}
lpPos = WINPOS_InitInternalPos( pWnd, *(LPPOINT)&pWnd->rectWindow.left, &pWnd->rectWindow );
lpPos = WINPOS_InitInternalPos( pWnd );
wndpl->length = sizeof(*wndpl);
if( pWnd->dwStyle & WS_MINIMIZE )
wndpl->showCmd = SW_SHOWMINIMIZED;
@ -914,7 +918,7 @@ BOOL WINAPI GetWindowPlacement( HWND hwnd, WINDOWPLACEMENT *wndpl )
wndpl->rcNormalPosition.top = lpPos->rectNormal.top;
wndpl->rcNormalPosition.right = lpPos->rectNormal.right;
wndpl->rcNormalPosition.bottom = lpPos->rectNormal.bottom;
WIN_ReleaseWndPtr(pWnd);
WIN_ReleasePtr( pWnd );
return TRUE;
}
@ -927,8 +931,7 @@ static BOOL WINPOS_SetPlacement( HWND hwnd, const WINDOWPLACEMENT *wndpl, UINT f
WND *pWnd = WIN_FindWndPtr( hwnd );
if( pWnd )
{
LPINTERNALPOS lpPos = (LPINTERNALPOS)WINPOS_InitInternalPos( pWnd,
*(LPPOINT)&pWnd->rectWindow.left, &pWnd->rectWindow );
LPINTERNALPOS lpPos = WINPOS_InitInternalPos( pWnd );
if( flags & PLACE_MIN )
{