Removed a number of direct accesses to the window structure.

oldstable
Alexandre Julliard 2001-08-18 18:08:26 +00:00
parent a3d3d40506
commit 4ff32c8aef
15 changed files with 1206 additions and 1600 deletions

View File

@ -73,4 +73,3 @@ debug_channels (ttydrv)
@ cdecl IsClipboardFormatAvailable(long) TTYDRV_IsClipboardFormatAvailable @ cdecl IsClipboardFormatAvailable(long) TTYDRV_IsClipboardFormatAvailable
@ cdecl RegisterClipboardFormat(str) TTYDRV_RegisterClipboardFormat @ cdecl RegisterClipboardFormat(str) TTYDRV_RegisterClipboardFormat
@ cdecl IsSelectionOwner() TTYDRV_IsSelectionOwner @ cdecl IsSelectionOwner() TTYDRV_IsSelectionOwner
@ cdecl ResetSelectionOwner(ptr long) TTYDRV_ResetSelectionOwner

View File

@ -212,10 +212,3 @@ BOOL TTYDRV_IsSelectionOwner(void)
{ {
return FALSE; return FALSE;
} }
/***********************************************************************
* ResetSelectionOwner (TTYDRV.@)
*/
void TTYDRV_ResetSelectionOwner(struct tagWND *pWnd, BOOL bFooBar)
{
}

View File

@ -28,7 +28,6 @@ LRESULT WINAPI SendMessage16( HWND16 hwnd, UINT16 msg, WPARAM16 wparam, LPARAM l
GetWindowThreadProcessId( hwnd, NULL ) == GetCurrentThreadId()) GetWindowThreadProcessId( hwnd, NULL ) == GetCurrentThreadId())
{ {
/* call 16-bit window proc directly */ /* call 16-bit window proc directly */
WND *wndPtr;
WNDPROC16 winproc; WNDPROC16 winproc;
/* first the WH_CALLWNDPROC hook */ /* first the WH_CALLWNDPROC hook */
@ -51,13 +50,7 @@ LRESULT WINAPI SendMessage16( HWND16 hwnd, UINT16 msg, WPARAM16 wparam, LPARAM l
} }
} }
if (!(wndPtr = WIN_FindWndPtr( hwnd ))) if (!(winproc = (WNDPROC16)GetWindowLong16( hwnd, GWL_WNDPROC ))) return 0;
{
WARN("invalid hwnd %04x\n", hwnd );
return 0;
}
winproc = (WNDPROC16)wndPtr->winproc;
WIN_ReleaseWndPtr( wndPtr );
SPY_EnterMessage( SPY_SENDMESSAGE16, hwnd, msg, wparam, lparam ); SPY_EnterMessage( SPY_SENDMESSAGE16, hwnd, msg, wparam, lparam );
result = CallWindowProc16( (WNDPROC16)winproc, hwnd, msg, wparam, lparam ); result = CallWindowProc16( (WNDPROC16)winproc, hwnd, msg, wparam, lparam );

View File

@ -1567,25 +1567,25 @@ static void draw_moving_frame( HDC hdc, RECT *rect, BOOL thickframe )
* Initialisation of a move or resize, when initiatied from a menu choice. * Initialisation of a move or resize, when initiatied from a menu choice.
* Return hit test code for caption or sizing border. * Return hit test code for caption or sizing border.
*/ */
static LONG start_size_move( WND* wndPtr, WPARAM wParam, POINT *capturePoint ) static LONG start_size_move( HWND hwnd, WPARAM wParam, POINT *capturePoint, LONG style )
{ {
LONG hittest = 0; LONG hittest = 0;
POINT pt; POINT pt;
MSG msg; MSG msg;
RECT rectWindow; RECT rectWindow;
GetWindowRect(wndPtr->hwndSelf,&rectWindow); GetWindowRect( hwnd, &rectWindow );
if ((wParam & 0xfff0) == SC_MOVE) if ((wParam & 0xfff0) == SC_MOVE)
{ {
/* Move pointer at the center of the caption */ /* Move pointer at the center of the caption */
RECT rect; RECT rect;
NC_GetInsideRect( wndPtr->hwndSelf, &rect ); NC_GetInsideRect( hwnd, &rect );
if (wndPtr->dwStyle & WS_SYSMENU) if (style & WS_SYSMENU)
rect.left += GetSystemMetrics(SM_CXSIZE) + 1; rect.left += GetSystemMetrics(SM_CXSIZE) + 1;
if (wndPtr->dwStyle & WS_MINIMIZEBOX) if (style & WS_MINIMIZEBOX)
rect.right -= GetSystemMetrics(SM_CXSIZE) + 1; rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
if (wndPtr->dwStyle & WS_MAXIMIZEBOX) if (style & WS_MAXIMIZEBOX)
rect.right -= GetSystemMetrics(SM_CXSIZE) + 1; rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
pt.x = rectWindow.left + (rect.right - rect.left) / 2; pt.x = rectWindow.left + (rect.right - rect.left) / 2;
pt.y = rectWindow.top + rect.top + GetSystemMetrics(SM_CYSIZE)/2; pt.y = rectWindow.top + rect.top + GetSystemMetrics(SM_CYSIZE)/2;
@ -1602,7 +1602,7 @@ static LONG start_size_move( WND* wndPtr, WPARAM wParam, POINT *capturePoint )
switch(msg.message) switch(msg.message)
{ {
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
hittest = NC_HandleNCHitTest( wndPtr->hwndSelf, msg.pt ); hittest = NC_HandleNCHitTest( hwnd, msg.pt );
if ((hittest < HTLEFT) || (hittest > HTBOTTOMRIGHT)) if ((hittest < HTLEFT) || (hittest > HTBOTTOMRIGHT))
hittest = 0; hittest = 0;
break; break;
@ -1641,8 +1641,7 @@ static LONG start_size_move( WND* wndPtr, WPARAM wParam, POINT *capturePoint )
*capturePoint = pt; *capturePoint = pt;
} }
SetCursorPos( pt.x, pt.y ); SetCursorPos( pt.x, pt.y );
NC_HandleSetCursor( wndPtr->hwndSelf, NC_HandleSetCursor( hwnd, hwnd, MAKELONG( hittest, WM_MOUSEMOVE ));
wndPtr->hwndSelf, MAKELONG( hittest, WM_MOUSEMOVE ));
return hittest; return hittest;
} }
@ -1657,13 +1656,15 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
MSG msg; MSG msg;
RECT sizingRect, mouseRect, origRect; RECT sizingRect, mouseRect, origRect;
HDC hdc; HDC hdc;
HWND parent;
LONG hittest = (LONG)(wParam & 0x0f); LONG hittest = (LONG)(wParam & 0x0f);
HCURSOR16 hDragCursor = 0, hOldCursor = 0; HCURSOR16 hDragCursor = 0, hOldCursor = 0;
POINT minTrack, maxTrack; POINT minTrack, maxTrack;
POINT capturePoint, pt; POINT capturePoint, pt;
WND * wndPtr = WIN_FindWndPtr( hwnd ); LONG style = GetWindowLongA( hwnd, GWL_STYLE );
BOOL thickframe = HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ); LONG exstyle = GetWindowLongA( hwnd, GWL_EXSTYLE );
BOOL iconic = wndPtr->dwStyle & WS_MINIMIZE; BOOL thickframe = HAS_THICKFRAME( style, exstyle );
BOOL iconic = style & WS_MINIMIZE;
BOOL moved = FALSE; BOOL moved = FALSE;
DWORD dwPoint = GetMessagePos (); DWORD dwPoint = GetMessagePos ();
BOOL DragFullWindows = FALSE; BOOL DragFullWindows = FALSE;
@ -1678,26 +1679,25 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
pt.y = SHIWORD(dwPoint); pt.y = SHIWORD(dwPoint);
capturePoint = pt; capturePoint = pt;
if (IsZoomed(hwnd) || !IsWindowVisible(hwnd) || if (IsZoomed(hwnd) || !IsWindowVisible(hwnd) || (exstyle & WS_EX_MANAGED)) return;
(wndPtr->dwExStyle & WS_EX_MANAGED)) goto END;
if ((wParam & 0xfff0) == SC_MOVE) if ((wParam & 0xfff0) == SC_MOVE)
{ {
if (!hittest) hittest = start_size_move( wndPtr, wParam, &capturePoint ); if (!hittest) hittest = start_size_move( hwnd, wParam, &capturePoint, style );
if (!hittest) goto END; if (!hittest) return;
} }
else /* SC_SIZE */ else /* SC_SIZE */
{ {
if (!thickframe) goto END; if (!thickframe) return;
if ( hittest && hittest != HTSYSMENU ) hittest += 2; if ( hittest && hittest != HTSYSMENU ) hittest += 2;
else else
{ {
SetCapture(hwnd); SetCapture(hwnd);
hittest = start_size_move( wndPtr, wParam, &capturePoint ); hittest = start_size_move( hwnd, wParam, &capturePoint, style );
if (!hittest) if (!hittest)
{ {
ReleaseCapture(); ReleaseCapture();
goto END; return;
} }
} }
} }
@ -1705,12 +1705,21 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
/* Get min/max info */ /* Get min/max info */
WINPOS_GetMinMaxInfo( hwnd, NULL, NULL, &minTrack, &maxTrack ); WINPOS_GetMinMaxInfo( hwnd, NULL, NULL, &minTrack, &maxTrack );
sizingRect = wndPtr->rectWindow; GetWindowRect( hwnd, &sizingRect );
origRect = sizingRect; if (style & WS_CHILD)
if (wndPtr->dwStyle & WS_CHILD) {
GetClientRect( wndPtr->parent->hwndSelf, &mouseRect ); parent = GetParent(hwnd);
/* make sizing rect relative to parent */
MapWindowPoints( 0, parent, (POINT*)&sizingRect, 2 );
GetClientRect( parent, &mouseRect );
}
else else
{
parent = 0;
SetRect(&mouseRect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); SetRect(&mouseRect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
}
origRect = sizingRect;
if (ON_LEFT_BORDER(hittest)) if (ON_LEFT_BORDER(hittest))
{ {
mouseRect.left = max( mouseRect.left, sizingRect.right-maxTrack.x ); mouseRect.left = max( mouseRect.left, sizingRect.right-maxTrack.x );
@ -1731,13 +1740,10 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
mouseRect.top = max( mouseRect.top, sizingRect.top+minTrack.y ); mouseRect.top = max( mouseRect.top, sizingRect.top+minTrack.y );
mouseRect.bottom = min( mouseRect.bottom, sizingRect.top+maxTrack.y ); mouseRect.bottom = min( mouseRect.bottom, sizingRect.top+maxTrack.y );
} }
if (wndPtr->dwStyle & WS_CHILD) if (parent) MapWindowPoints( parent, 0, (LPPOINT)&mouseRect, 2 );
{
MapWindowPoints( wndPtr->parent->hwndSelf, 0, (LPPOINT)&mouseRect, 2 );
}
/* Retrieve a default cache DC (without using the window style) */ /* Retrieve a default cache DC (without using the window style) */
hdc = GetDCEx( wndPtr->parent->hwndSelf, 0, DCX_CACHE ); hdc = GetDCEx( parent, 0, DCX_CACHE );
if( iconic ) /* create a cursor for dragging */ if( iconic ) /* create a cursor for dragging */
{ {
@ -1754,8 +1760,7 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
SetCapture( hwnd ); SetCapture( hwnd );
/* grab the server only when moving top-level windows without desktop */ /* grab the server only when moving top-level windows without desktop */
grab = (!DragFullWindows && (root_window == DefaultRootWindow(gdi_display)) && grab = (!DragFullWindows && !parent && (root_window == DefaultRootWindow(gdi_display)));
(wndPtr->parent->hwndSelf == GetDesktopWindow()));
wine_tsx11_lock(); wine_tsx11_lock();
if (grab) if (grab)
@ -1767,9 +1772,10 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
old_gdi_display = gdi_display; old_gdi_display = gdi_display;
gdi_display = display; gdi_display = display;
} }
XGrabPointer( display, get_whole_window(wndPtr), False, XGrabPointer( display, X11DRV_get_whole_window(hwnd), False,
PointerMotionMask | ButtonPressMask | ButtonReleaseMask, PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
GrabModeAsync, GrabModeAsync, get_client_window(wndPtr->parent), GrabModeAsync, GrabModeAsync,
parent ? X11DRV_get_client_window(parent) : root_window,
None, CurrentTime ); None, CurrentTime );
wine_tsx11_unlock(); wine_tsx11_unlock();
@ -1874,7 +1880,7 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
else if (moved && !DragFullWindows) else if (moved && !DragFullWindows)
draw_moving_frame( hdc, &sizingRect, thickframe ); draw_moving_frame( hdc, &sizingRect, thickframe );
ReleaseDC( wndPtr->parent->hwndSelf, hdc ); ReleaseDC( parent, hdc );
wine_tsx11_lock(); wine_tsx11_lock();
XUngrabPointer( display, CurrentTime ); XUngrabPointer( display, CurrentTime );
@ -1887,8 +1893,7 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
} }
wine_tsx11_unlock(); wine_tsx11_unlock();
if (HOOK_CallHooksA( WH_CBT, HCBT_MOVESIZE, hwnd, (LPARAM)&sizingRect )) if (HOOK_CallHooksA( WH_CBT, HCBT_MOVESIZE, hwnd, (LPARAM)&sizingRect )) moved = FALSE;
sizingRect = wndPtr->rectWindow;
SendMessageA( hwnd, WM_EXITSIZEMOVE, 0, 0 ); SendMessageA( hwnd, WM_EXITSIZEMOVE, 0, 0 );
SendMessageA( hwnd, WM_SETVISIBLE, !IsIconic(hwnd), 0L); SendMessageA( hwnd, WM_SETVISIBLE, !IsIconic(hwnd), 0L);
@ -1930,15 +1935,12 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
if( !moved ) if( !moved )
{ {
if( wndPtr->dwStyle & WS_SYSMENU ) if(style & WS_SYSMENU )
SendMessageA( hwnd, WM_SYSCOMMAND, SendMessageA( hwnd, WM_SYSCOMMAND,
SC_MOUSEMENU + HTSYSMENU, MAKELONG(pt.x,pt.y)); SC_MOUSEMENU + HTSYSMENU, MAKELONG(pt.x,pt.y));
} }
else WINPOS_ShowIconTitle( hwnd, TRUE ); else WINPOS_ShowIconTitle( hwnd, TRUE );
} }
END:
WIN_ReleaseWndPtr(wndPtr);
} }

View File

@ -67,7 +67,7 @@ typedef struct tagUSER_DRIVER {
BOOL (*pIsClipboardFormatAvailable)(UINT); /* Check if specified format is available */ BOOL (*pIsClipboardFormatAvailable)(UINT); /* Check if specified format is available */
BOOL (*pRegisterClipboardFormat)(LPCSTR); /* Register a clipboard format */ BOOL (*pRegisterClipboardFormat)(LPCSTR); /* Register a clipboard format */
BOOL (*pIsSelectionOwner)(void); /* Check if we own the selection */ BOOL (*pIsSelectionOwner)(void); /* Check if we own the selection */
void (*pResetSelectionOwner)(struct tagWND *, BOOL); void (*pResetSelectionOwner)(HWND, BOOL);
/* windowing functions */ /* windowing functions */
BOOL (*pCreateWindow)(HWND,CREATESTRUCTA*,BOOL); BOOL (*pCreateWindow)(HWND,CREATESTRUCTA*,BOOL);

View File

@ -77,12 +77,6 @@ typedef struct
#define WIN_NEEDS_SHOW_OWNEDPOPUP 0x0800 /* WM_SHOWWINDOW:SC_SHOW must be sent in the next ShowOwnedPopup call */ #define WIN_NEEDS_SHOW_OWNEDPOPUP 0x0800 /* WM_SHOWWINDOW:SC_SHOW must be sent in the next ShowOwnedPopup call */
#define WIN_NEEDS_INTERNALSOP 0x1000 /* Window was hidden by WIN_InternalShowOwnedPopups */ #define WIN_NEEDS_INTERNALSOP 0x1000 /* Window was hidden by WIN_InternalShowOwnedPopups */
/* BuildWinArray() flags */
#define BWA_SKIPDISABLED 0x0001
#define BWA_SKIPHIDDEN 0x0002
#define BWA_SKIPOWNED 0x0004
#define BWA_SKIPICONIC 0x0008
/* Window functions */ /* Window functions */
extern int WIN_SuspendWndsLock( void ); extern int WIN_SuspendWndsLock( void );
extern void WIN_RestoreWndsLock(int ipreviousLock); extern void WIN_RestoreWndsLock(int ipreviousLock);
@ -102,16 +96,14 @@ extern BOOL WIN_CreateDesktopWindow(void);
extern HWND WIN_GetTopParent( HWND hwnd ); extern HWND WIN_GetTopParent( HWND hwnd );
extern WND* WIN_GetTopParentPtr( WND* pWnd ); extern WND* WIN_GetTopParentPtr( WND* pWnd );
extern BOOL WIN_IsWindowDrawable(WND*, BOOL ); extern BOOL WIN_IsWindowDrawable(WND*, BOOL );
extern WND** WIN_BuildWinArray( WND *wndPtr, UINT bwa, UINT* pnum ); extern HWND *WIN_BuildWinArray( HWND hwnd );
extern void WIN_ReleaseWinArray(WND **wndArray); extern void WIN_ReleaseWinArray( HWND *wndArray );
extern BOOL WIN_InternalShowOwnedPopups( HWND owner, BOOL fShow, BOOL unmanagedOnly ); extern BOOL WIN_InternalShowOwnedPopups( HWND owner, BOOL fShow, BOOL unmanagedOnly );
extern HWND CARET_GetHwnd(void); extern HWND CARET_GetHwnd(void);
extern void CARET_GetRect(LPRECT lprc); /* windows/caret.c */ extern void CARET_GetRect(LPRECT lprc); /* windows/caret.c */
extern BOOL16 DRAG_QueryUpdate( HWND, SEGPTR, BOOL ); extern BOOL16 DRAG_QueryUpdate( HWND, SEGPTR, BOOL );
extern void DEFWND_SetTextA( WND *wndPtr, LPCSTR text );
extern void DEFWND_SetTextW( WND *wndPtr, LPCWSTR text );
extern HBRUSH DEFWND_ControlColor( HDC hDC, UINT ctlType ); /* windows/defwnd.c */ extern HBRUSH DEFWND_ControlColor( HDC hDC, UINT ctlType ); /* windows/defwnd.c */
extern void PROPERTY_RemoveWindowProps( WND *pWnd ); /* windows/property.c */ extern void PROPERTY_RemoveWindowProps( WND *pWnd ); /* windows/property.c */

View File

@ -38,32 +38,45 @@ static void DEFDLG_SetFocus( HWND hwndDlg, HWND hwndCtrl )
/*********************************************************************** /***********************************************************************
* DEFDLG_SaveFocus * DEFDLG_SaveFocus
*/ */
static BOOL DEFDLG_SaveFocus( HWND hwnd, DIALOGINFO *infoPtr ) static void DEFDLG_SaveFocus( HWND hwnd )
{ {
DIALOGINFO *infoPtr;
WND *wndPtr;
HWND hwndFocus = GetFocus(); HWND hwndFocus = GetFocus();
if (!hwndFocus || !IsChild( hwnd, hwndFocus )) return FALSE; if (!hwndFocus || !IsChild( hwnd, hwndFocus )) return;
if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return;
infoPtr = (DIALOGINFO *)&wndPtr->wExtra;
infoPtr->hwndFocus = hwndFocus; infoPtr->hwndFocus = hwndFocus;
WIN_ReleaseWndPtr( wndPtr );
/* Remove default button */ /* Remove default button */
return TRUE;
} }
/*********************************************************************** /***********************************************************************
* DEFDLG_RestoreFocus * DEFDLG_RestoreFocus
*/ */
static BOOL DEFDLG_RestoreFocus( HWND hwnd, DIALOGINFO *infoPtr ) static void DEFDLG_RestoreFocus( HWND hwnd )
{ {
if (!infoPtr->hwndFocus || IsIconic(hwnd)) return FALSE; DIALOGINFO *infoPtr;
if (!IsWindow( infoPtr->hwndFocus )) return FALSE; WND *wndPtr;
if (IsIconic( hwnd )) return;
if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return;
infoPtr = (DIALOGINFO *)&wndPtr->wExtra;
if (IsWindow( infoPtr->hwndFocus ))
{
/* Don't set the focus back to controls if EndDialog is already called.*/ /* Don't set the focus back to controls if EndDialog is already called.*/
if (!(infoPtr->flags & DF_END)) if (!(infoPtr->flags & DF_END))
{
WIN_ReleaseWndPtr( wndPtr );
DEFDLG_SetFocus( hwnd, infoPtr->hwndFocus ); DEFDLG_SetFocus( hwnd, infoPtr->hwndFocus );
return;
}
/* This used to set infoPtr->hwndFocus to NULL for no apparent reason, /* This used to set infoPtr->hwndFocus to NULL for no apparent reason,
sometimes losing focus when receiving WM_SETFOCUS messages. */ sometimes losing focus when receiving WM_SETFOCUS messages. */
return TRUE; }
WIN_ReleaseWndPtr( wndPtr );
} }
@ -161,16 +174,16 @@ static LRESULT DEFDLG_Proc( HWND hwnd, UINT msg, WPARAM wParam,
return DefWindowProcA( hwnd, msg, wParam, lParam ); return DefWindowProcA( hwnd, msg, wParam, lParam );
case WM_SHOWWINDOW: case WM_SHOWWINDOW:
if (!wParam) DEFDLG_SaveFocus( hwnd, dlgInfo ); if (!wParam) DEFDLG_SaveFocus( hwnd );
return DefWindowProcA( hwnd, msg, wParam, lParam ); return DefWindowProcA( hwnd, msg, wParam, lParam );
case WM_ACTIVATE: case WM_ACTIVATE:
if (wParam) DEFDLG_RestoreFocus( hwnd, dlgInfo ); if (wParam) DEFDLG_RestoreFocus( hwnd );
else DEFDLG_SaveFocus( hwnd, dlgInfo ); else DEFDLG_SaveFocus( hwnd );
return 0; return 0;
case WM_SETFOCUS: case WM_SETFOCUS:
DEFDLG_RestoreFocus( hwnd, dlgInfo ); DEFDLG_RestoreFocus( hwnd );
return 0; return 0;
case DM_SETDEFID: case DM_SETDEFID:
@ -231,7 +244,7 @@ static LRESULT DEFDLG_Proc( HWND hwnd, UINT msg, WPARAM wParam,
/*********************************************************************** /***********************************************************************
* DEFDLG_Epilog * DEFDLG_Epilog
*/ */
static LRESULT DEFDLG_Epilog(DIALOGINFO* dlgInfo, UINT msg, BOOL fResult) static LRESULT DEFDLG_Epilog(HWND hwnd, UINT msg, BOOL fResult)
{ {
/* see SDK 3.1 */ /* see SDK 3.1 */
@ -241,7 +254,7 @@ static LRESULT DEFDLG_Epilog(DIALOGINFO* dlgInfo, UINT msg, BOOL fResult)
msg == WM_QUERYDRAGICON || msg == WM_INITDIALOG) msg == WM_QUERYDRAGICON || msg == WM_INITDIALOG)
return fResult; return fResult;
return dlgInfo->msgResult; return GetWindowLongA( hwnd, DWL_MSGRESULT );
} }
/*********************************************************************** /***********************************************************************
@ -251,18 +264,22 @@ LRESULT WINAPI DefDlgProc16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam,
LPARAM lParam ) LPARAM lParam )
{ {
DIALOGINFO * dlgInfo; DIALOGINFO * dlgInfo;
WNDPROC16 dlgproc;
BOOL result = FALSE; BOOL result = FALSE;
WND * wndPtr = WIN_FindWndPtr( hwnd ); WND * wndPtr = WIN_FindWndPtr( hwnd );
if (!wndPtr) return 0; if (!wndPtr) return 0;
dlgInfo = (DIALOGINFO *)&wndPtr->wExtra; dlgInfo = (DIALOGINFO *)&wndPtr->wExtra;
dlgInfo->msgResult = 0; dlgInfo->msgResult = 0;
dlgproc = (WNDPROC16)dlgInfo->dlgProc;
WIN_ReleaseWndPtr(wndPtr);
if (dlgInfo->dlgProc) { /* Call dialog procedure */ if (dlgproc)
result = CallWindowProc16( (WNDPROC16)dlgInfo->dlgProc, {
hwnd, msg, wParam, lParam ); /* Call dialog procedure */
result = CallWindowProc16( dlgproc, hwnd, msg, wParam, lParam );
/* 16 bit dlg procs only return BOOL16 */ /* 16 bit dlg procs only return BOOL16 */
if( WINPROC_GetProcType( dlgInfo->dlgProc ) == WIN_PROC_16 ) if( WINPROC_GetProcType( dlgproc ) == WIN_PROC_16 )
result = LOWORD(result); result = LOWORD(result);
} }
@ -285,7 +302,6 @@ LRESULT WINAPI DefDlgProc16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam,
case WM_ENTERMENULOOP: case WM_ENTERMENULOOP:
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
case WM_NCLBUTTONDOWN: case WM_NCLBUTTONDOWN:
WIN_ReleaseWndPtr(wndPtr);
return DEFDLG_Proc( (HWND)hwnd, msg, return DEFDLG_Proc( (HWND)hwnd, msg,
(WPARAM)wParam, lParam, dlgInfo ); (WPARAM)wParam, lParam, dlgInfo );
case WM_INITDIALOG: case WM_INITDIALOG:
@ -295,12 +311,10 @@ LRESULT WINAPI DefDlgProc16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam,
break; break;
default: default:
WIN_ReleaseWndPtr(wndPtr);
return DefWindowProc16( hwnd, msg, wParam, lParam ); return DefWindowProc16( hwnd, msg, wParam, lParam );
} }
} }
WIN_ReleaseWndPtr(wndPtr); return DEFDLG_Epilog(hwnd, msg, result);
return DEFDLG_Epilog(dlgInfo, msg, result);
} }
@ -311,18 +325,22 @@ LRESULT WINAPI DefDlgProcA( HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam ) WPARAM wParam, LPARAM lParam )
{ {
DIALOGINFO * dlgInfo; DIALOGINFO * dlgInfo;
WNDPROC dlgproc;
BOOL result = FALSE; BOOL result = FALSE;
WND * wndPtr = WIN_FindWndPtr( hwnd ); WND * wndPtr = WIN_FindWndPtr( hwnd );
if (!wndPtr) return 0; if (!wndPtr) return 0;
dlgInfo = (DIALOGINFO *)&wndPtr->wExtra; dlgInfo = (DIALOGINFO *)&wndPtr->wExtra;
dlgInfo->msgResult = 0; dlgInfo->msgResult = 0;
dlgproc = dlgInfo->dlgProc;
WIN_ReleaseWndPtr(wndPtr);
if (dlgInfo->dlgProc) { /* Call dialog procedure */ if (dlgproc)
result = CallWindowProcA( (WNDPROC)dlgInfo->dlgProc, {
hwnd, msg, wParam, lParam ); /* Call dialog procedure */
result = CallWindowProcA( dlgproc, hwnd, msg, wParam, lParam );
/* 16 bit dlg procs only return BOOL16 */ /* 16 bit dlg procs only return BOOL16 */
if( WINPROC_GetProcType( dlgInfo->dlgProc ) == WIN_PROC_16 ) if( WINPROC_GetProcType( dlgproc ) == WIN_PROC_16 )
result = LOWORD(result); result = LOWORD(result);
} }
@ -345,9 +363,7 @@ LRESULT WINAPI DefDlgProcA( HWND hwnd, UINT msg,
case WM_ENTERMENULOOP: case WM_ENTERMENULOOP:
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
case WM_NCLBUTTONDOWN: case WM_NCLBUTTONDOWN:
WIN_ReleaseWndPtr(wndPtr); return DEFDLG_Proc( hwnd, msg, wParam, lParam, dlgInfo );
return DEFDLG_Proc( (HWND)hwnd, msg,
(WPARAM)wParam, lParam, dlgInfo );
case WM_INITDIALOG: case WM_INITDIALOG:
case WM_VKEYTOITEM: case WM_VKEYTOITEM:
case WM_COMPAREITEM: case WM_COMPAREITEM:
@ -355,12 +371,10 @@ LRESULT WINAPI DefDlgProcA( HWND hwnd, UINT msg,
break; break;
default: default:
WIN_ReleaseWndPtr(wndPtr);
return DefWindowProcA( hwnd, msg, wParam, lParam ); return DefWindowProcA( hwnd, msg, wParam, lParam );
} }
} }
WIN_ReleaseWndPtr(wndPtr); return DEFDLG_Epilog(hwnd, msg, result);
return DEFDLG_Epilog(dlgInfo, msg, result);
} }
@ -372,17 +386,21 @@ LRESULT WINAPI DefDlgProcW( HWND hwnd, UINT msg, WPARAM wParam,
{ {
DIALOGINFO * dlgInfo; DIALOGINFO * dlgInfo;
BOOL result = FALSE; BOOL result = FALSE;
WNDPROC dlgproc;
WND * wndPtr = WIN_FindWndPtr( hwnd ); WND * wndPtr = WIN_FindWndPtr( hwnd );
if (!wndPtr) return 0; if (!wndPtr) return 0;
dlgInfo = (DIALOGINFO *)&wndPtr->wExtra; dlgInfo = (DIALOGINFO *)&wndPtr->wExtra;
dlgInfo->msgResult = 0; dlgInfo->msgResult = 0;
dlgproc = dlgInfo->dlgProc;
WIN_ReleaseWndPtr(wndPtr);
if (dlgInfo->dlgProc) { /* Call dialog procedure */ if (dlgproc)
result = CallWindowProcW( (WNDPROC)dlgInfo->dlgProc, {
hwnd, msg, wParam, lParam ); /* Call dialog procedure */
result = CallWindowProcW( dlgproc, hwnd, msg, wParam, lParam );
/* 16 bit dlg procs only return BOOL16 */ /* 16 bit dlg procs only return BOOL16 */
if( WINPROC_GetProcType( dlgInfo->dlgProc ) == WIN_PROC_16 ) if( WINPROC_GetProcType( dlgproc ) == WIN_PROC_16 )
result = LOWORD(result); result = LOWORD(result);
} }
@ -405,9 +423,7 @@ LRESULT WINAPI DefDlgProcW( HWND hwnd, UINT msg, WPARAM wParam,
case WM_ENTERMENULOOP: case WM_ENTERMENULOOP:
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
case WM_NCLBUTTONDOWN: case WM_NCLBUTTONDOWN:
WIN_ReleaseWndPtr(wndPtr); return DEFDLG_Proc( hwnd, msg, wParam, lParam, dlgInfo );
return DEFDLG_Proc( (HWND)hwnd, msg,
(WPARAM)wParam, lParam, dlgInfo );
case WM_INITDIALOG: case WM_INITDIALOG:
case WM_VKEYTOITEM: case WM_VKEYTOITEM:
case WM_COMPAREITEM: case WM_COMPAREITEM:
@ -415,10 +431,8 @@ LRESULT WINAPI DefDlgProcW( HWND hwnd, UINT msg, WPARAM wParam,
break; break;
default: default:
WIN_ReleaseWndPtr(wndPtr);
return DefWindowProcW( hwnd, msg, wParam, lParam ); return DefWindowProcW( hwnd, msg, wParam, lParam );
} }
} }
WIN_ReleaseWndPtr(wndPtr); return DEFDLG_Epilog(hwnd, msg, result);
return DEFDLG_Epilog(dlgInfo, msg, result);
} }

View File

@ -35,21 +35,24 @@ static short iMenuSysKey = 0;
* *
* Handle the WM_WINDOWPOSCHANGED message. * Handle the WM_WINDOWPOSCHANGED message.
*/ */
static void DEFWND_HandleWindowPosChanged( WND *wndPtr, UINT flags ) static void DEFWND_HandleWindowPosChanged( HWND hwnd, UINT flags )
{ {
WPARAM wp = SIZE_RESTORED; RECT rect;
WND *wndPtr = WIN_FindWndPtr( hwnd );
rect = wndPtr->rectClient;
WIN_ReleaseWndPtr( wndPtr );
if (!(flags & SWP_NOCLIENTMOVE)) if (!(flags & SWP_NOCLIENTMOVE))
SendMessageW( wndPtr->hwndSelf, WM_MOVE, 0, SendMessageW( hwnd, WM_MOVE, 0, MAKELONG(rect.left, rect.top));
MAKELONG(wndPtr->rectClient.left, wndPtr->rectClient.top));
if (!(flags & SWP_NOCLIENTSIZE)) if (!(flags & SWP_NOCLIENTSIZE))
{ {
if (wndPtr->dwStyle & WS_MAXIMIZE) wp = SIZE_MAXIMIZED; WPARAM wp = SIZE_RESTORED;
else if (wndPtr->dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED; if (IsZoomed(hwnd)) wp = SIZE_MAXIMIZED;
else if (IsIconic(hwnd)) wp = SIZE_MINIMIZED;
SendMessageW( wndPtr->hwndSelf, WM_SIZE, wp, SendMessageW( hwnd, WM_SIZE, wp, MAKELONG(rect.right-rect.left, rect.bottom-rect.top) );
MAKELONG(wndPtr->rectClient.right-wndPtr->rectClient.left,
wndPtr->rectClient.bottom-wndPtr->rectClient.top));
} }
} }
@ -59,21 +62,24 @@ static void DEFWND_HandleWindowPosChanged( WND *wndPtr, UINT flags )
* *
* Set the window text. * Set the window text.
*/ */
void DEFWND_SetTextA( WND *wndPtr, LPCSTR text ) static void DEFWND_SetTextA( HWND hwnd, LPCSTR text )
{ {
int count; int count;
WCHAR *textW;
WND *wndPtr;
if (!text) text = ""; if (!text) text = "";
count = MultiByteToWideChar( CP_ACP, 0, text, -1, NULL, 0 ); count = MultiByteToWideChar( CP_ACP, 0, text, -1, NULL, 0 );
if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return;
if (wndPtr->text) HeapFree(GetProcessHeap(), 0, wndPtr->text); if (wndPtr->text) HeapFree(GetProcessHeap(), 0, wndPtr->text);
if ((wndPtr->text = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WCHAR)))) if ((wndPtr->text = textW = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WCHAR))))
MultiByteToWideChar( CP_ACP, 0, text, -1, wndPtr->text, count ); MultiByteToWideChar( CP_ACP, 0, text, -1, wndPtr->text, count );
else else
ERR("Not enough memory for window text\n"); ERR("Not enough memory for window text\n");
WIN_ReleaseWndPtr( wndPtr );
if (USER_Driver.pSetWindowText) if (USER_Driver.pSetWindowText) USER_Driver.pSetWindowText( hwnd, textW );
USER_Driver.pSetWindowText(wndPtr->hwndSelf, wndPtr->text);
} }
/*********************************************************************** /***********************************************************************
@ -81,22 +87,25 @@ void DEFWND_SetTextA( WND *wndPtr, LPCSTR text )
* *
* Set the window text. * Set the window text.
*/ */
void DEFWND_SetTextW( WND *wndPtr, LPCWSTR text ) static void DEFWND_SetTextW( HWND hwnd, LPCWSTR text )
{ {
static const WCHAR empty_string[] = {0}; static const WCHAR empty_string[] = {0};
WND *wndPtr;
int count; int count;
if (!text) text = empty_string; if (!text) text = empty_string;
count = strlenW(text) + 1; count = strlenW(text) + 1;
if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return;
if (wndPtr->text) HeapFree(GetProcessHeap(), 0, wndPtr->text); if (wndPtr->text) HeapFree(GetProcessHeap(), 0, wndPtr->text);
if ((wndPtr->text = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WCHAR)))) if ((wndPtr->text = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WCHAR))))
strcpyW( wndPtr->text, text ); strcpyW( wndPtr->text, text );
else else
ERR("Not enough memory for window text\n"); ERR("Not enough memory for window text\n");
text = wndPtr->text;
WIN_ReleaseWndPtr( wndPtr );
if (USER_Driver.pSetWindowText) if (USER_Driver.pSetWindowText) USER_Driver.pSetWindowText( hwnd, text );
USER_Driver.pSetWindowText(wndPtr->hwndSelf, wndPtr->text);
} }
/*********************************************************************** /***********************************************************************
@ -148,8 +157,9 @@ HBRUSH DEFWND_ControlColor( HDC hDC, UINT ctlType )
/*********************************************************************** /***********************************************************************
* DEFWND_SetRedraw * DEFWND_SetRedraw
*/ */
static void DEFWND_SetRedraw( WND* wndPtr, WPARAM wParam ) static void DEFWND_SetRedraw( HWND hwnd, WPARAM wParam )
{ {
WND *wndPtr = WIN_FindWndPtr( hwnd );
BOOL bVisible = wndPtr->dwStyle & WS_VISIBLE; BOOL bVisible = wndPtr->dwStyle & WS_VISIBLE;
TRACE("%04x %i\n", wndPtr->hwndSelf, (wParam!=0) ); TRACE("%04x %i\n", wndPtr->hwndSelf, (wParam!=0) );
@ -171,6 +181,7 @@ static void DEFWND_SetRedraw( WND* wndPtr, WPARAM wParam )
DCE_InvalidateDCE( wndPtr, &wndPtr->rectWindow ); DCE_InvalidateDCE( wndPtr, &wndPtr->rectWindow );
wndPtr->dwStyle &= ~WS_VISIBLE; wndPtr->dwStyle &= ~WS_VISIBLE;
} }
WIN_ReleaseWndPtr( wndPtr );
} }
/*********************************************************************** /***********************************************************************
@ -178,16 +189,13 @@ static void DEFWND_SetRedraw( WND* wndPtr, WPARAM wParam )
* *
* This method handles the default behavior for the WM_PRINT message. * This method handles the default behavior for the WM_PRINT message.
*/ */
static void DEFWND_Print( static void DEFWND_Print( HWND hwnd, HDC hdc, ULONG uFlags)
WND* wndPtr,
HDC hdc,
ULONG uFlags)
{ {
/* /*
* Visibility flag. * Visibility flag.
*/ */
if ( (uFlags & PRF_CHECKVISIBLE) && if ( (uFlags & PRF_CHECKVISIBLE) &&
!IsWindowVisible(wndPtr->hwndSelf) ) !IsWindowVisible(hwnd) )
return; return;
/* /*
@ -204,13 +212,13 @@ static void DEFWND_Print(
* Background * Background
*/ */
if ( uFlags & PRF_ERASEBKGND) if ( uFlags & PRF_ERASEBKGND)
SendMessageW(wndPtr->hwndSelf, WM_ERASEBKGND, (WPARAM)hdc, 0); SendMessageW(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0);
/* /*
* Client area * Client area
*/ */
if ( uFlags & PRF_CLIENT) if ( uFlags & PRF_CLIENT)
SendMessageW(wndPtr->hwndSelf, WM_PRINTCLIENT, (WPARAM)hdc, PRF_CLIENT); SendMessageW(hwnd, WM_PRINTCLIENT, (WPARAM)hdc, PRF_CLIENT);
} }
@ -284,40 +292,33 @@ static BOOL DEFWND_ImmIsUIMessageW( HWND hwndIME, UINT msg, WPARAM wParam, LPARA
* *
* Default window procedure for messages that are the same in Win16 and Win32. * Default window procedure for messages that are the same in Win16 and Win32.
*/ */
static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam, static LRESULT DEFWND_DefWinProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
LPARAM lParam, BOOL unicode )
{ {
LRESULT (WINAPI *pSendMessage)(HWND, UINT, WPARAM, LPARAM);
BOOL (WINAPI *pPostMessage)(HWND, UINT, WPARAM, LPARAM);
pSendMessage = unicode ? SendMessageW : SendMessageA;
pPostMessage = unicode ? PostMessageW : PostMessageA;
switch(msg) switch(msg)
{ {
case WM_NCPAINT: case WM_NCPAINT:
return NC_HandleNCPaint( wndPtr->hwndSelf, (HRGN)wParam ); return NC_HandleNCPaint( hwnd, (HRGN)wParam );
case WM_NCHITTEST: case WM_NCHITTEST:
{ {
POINT pt; POINT pt;
pt.x = SLOWORD(lParam); pt.x = SLOWORD(lParam);
pt.y = SHIWORD(lParam); pt.y = SHIWORD(lParam);
return NC_HandleNCHitTest( wndPtr->hwndSelf, pt ); return NC_HandleNCHitTest( hwnd, pt );
} }
case WM_NCLBUTTONDOWN: case WM_NCLBUTTONDOWN:
return NC_HandleNCLButtonDown( wndPtr->hwndSelf, wParam, lParam ); return NC_HandleNCLButtonDown( hwnd, wParam, lParam );
case WM_LBUTTONDBLCLK: case WM_LBUTTONDBLCLK:
case WM_NCLBUTTONDBLCLK: case WM_NCLBUTTONDBLCLK:
return NC_HandleNCLButtonDblClk( wndPtr->hwndSelf, wParam, lParam ); return NC_HandleNCLButtonDblClk( hwnd, wParam, lParam );
case WM_NCRBUTTONDOWN: case WM_NCRBUTTONDOWN:
/* in Windows, capture is taken when right-clicking on the caption bar */ /* in Windows, capture is taken when right-clicking on the caption bar */
if (wParam==HTCAPTION) if (wParam==HTCAPTION)
{ {
SetCapture(wndPtr->hwndSelf); SetCapture(hwnd);
} }
break; break;
@ -325,15 +326,14 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
{ {
POINT pt; POINT pt;
if (wndPtr->hwndSelf == GetCapture()) if (hwnd == GetCapture())
/* release capture if we took it on WM_NCRBUTTONDOWN */ /* release capture if we took it on WM_NCRBUTTONDOWN */
ReleaseCapture(); ReleaseCapture();
pt.x = SLOWORD(lParam); pt.x = SLOWORD(lParam);
pt.y = SHIWORD(lParam); pt.y = SHIWORD(lParam);
ClientToScreen(wndPtr->hwndSelf, &pt); ClientToScreen(hwnd, &pt);
pSendMessage( wndPtr->hwndSelf, WM_CONTEXTMENU, SendMessageW( hwnd, WM_CONTEXTMENU, hwnd, MAKELPARAM(pt.x, pt.y) );
wndPtr->hwndSelf, MAKELPARAM(pt.x, pt.y) );
} }
break; break;
@ -347,89 +347,89 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
break; break;
case WM_CONTEXTMENU: case WM_CONTEXTMENU:
if( wndPtr->dwStyle & WS_CHILD ) if (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD)
pSendMessage( wndPtr->parent->hwndSelf, msg, wParam, lParam ); SendMessageW( GetParent(hwnd), msg, wParam, lParam );
else if (wndPtr->hSysMenu) else
{ {
LONG hitcode; LONG hitcode;
POINT pt; POINT pt;
WND *wndPtr = WIN_FindWndPtr( hwnd );
HMENU hMenu = wndPtr->hSysMenu;
WIN_ReleaseWndPtr( wndPtr );
if (!hMenu) return 0;
pt.x = SLOWORD(lParam); pt.x = SLOWORD(lParam);
pt.y = SHIWORD(lParam); pt.y = SHIWORD(lParam);
hitcode = NC_HandleNCHitTest(hwnd, pt);
/*
* WM_CONTEXTMENU coordinates are relative to screen, but
* NC_HandleNCHitTest expects coordinates relative to the parent's
* client area (to compare with the rectangle returned by
* GetWindowRect)
*/
if (wndPtr->parent)
ScreenToClient(wndPtr->parent->hwndSelf, &pt);
hitcode = NC_HandleNCHitTest(wndPtr->hwndSelf, pt);
/* Track system popup if click was in the caption area. */ /* Track system popup if click was in the caption area. */
if (hitcode==HTCAPTION || hitcode==HTSYSMENU) if (hitcode==HTCAPTION || hitcode==HTSYSMENU)
TrackPopupMenu(GetSystemMenu(wndPtr->hwndSelf, FALSE), TrackPopupMenu(GetSystemMenu(hwnd, FALSE),
TPM_LEFTBUTTON | TPM_RIGHTBUTTON, TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
pt.x, pt.y, 0, wndPtr->hwndSelf, NULL); pt.x, pt.y, 0, hwnd, NULL);
} }
break; break;
case WM_NCACTIVATE: case WM_NCACTIVATE:
return NC_HandleNCActivate( wndPtr->hwndSelf, wParam ); return NC_HandleNCActivate( hwnd, wParam );
case WM_NCDESTROY: case WM_NCDESTROY:
{
WND *wndPtr = WIN_FindWndPtr( hwnd );
if (!wndPtr) return 0;
if (wndPtr->text) HeapFree( GetProcessHeap(), 0, wndPtr->text ); if (wndPtr->text) HeapFree( GetProcessHeap(), 0, wndPtr->text );
wndPtr->text = NULL; wndPtr->text = NULL;
if (wndPtr->pVScroll) HeapFree( GetProcessHeap(), 0, wndPtr->pVScroll ); if (wndPtr->pVScroll) HeapFree( GetProcessHeap(), 0, wndPtr->pVScroll );
if (wndPtr->pHScroll) HeapFree( GetProcessHeap(), 0, wndPtr->pHScroll ); if (wndPtr->pHScroll) HeapFree( GetProcessHeap(), 0, wndPtr->pHScroll );
wndPtr->pVScroll = wndPtr->pHScroll = NULL; wndPtr->pVScroll = wndPtr->pHScroll = NULL;
WIN_ReleaseWndPtr( wndPtr );
return 0; return 0;
}
case WM_PRINT: case WM_PRINT:
DEFWND_Print(wndPtr, (HDC)wParam, lParam); DEFWND_Print(hwnd, (HDC)wParam, lParam);
return 0; return 0;
case WM_PAINTICON: case WM_PAINTICON:
case WM_PAINT: case WM_PAINT:
{ {
PAINTSTRUCT ps; PAINTSTRUCT ps;
HDC hdc = BeginPaint( wndPtr->hwndSelf, &ps ); HDC hdc = BeginPaint( hwnd, &ps );
if( hdc ) if( hdc )
{ {
HICON hIcon; HICON hIcon;
if( (wndPtr->dwStyle & WS_MINIMIZE) && ((hIcon = GetClassLongW( wndPtr->hwndSelf, GCL_HICON))) ) if (IsIconic(hwnd) && ((hIcon = GetClassLongW( hwnd, GCL_HICON))) )
{ {
int x = (wndPtr->rectWindow.right - wndPtr->rectWindow.left - RECT rc;
GetSystemMetrics(SM_CXICON))/2; int x, y;
int y = (wndPtr->rectWindow.bottom - wndPtr->rectWindow.top -
GetSystemMetrics(SM_CYICON))/2; GetClientRect( hwnd, &rc );
x = (rc.right - rc.left - GetSystemMetrics(SM_CXICON))/2;
y = (rc.bottom - rc.top - GetSystemMetrics(SM_CYICON))/2;
TRACE("Painting class icon: vis rect=(%i,%i - %i,%i)\n", TRACE("Painting class icon: vis rect=(%i,%i - %i,%i)\n",
ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom ); ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom );
DrawIcon( hdc, x, y, hIcon ); DrawIcon( hdc, x, y, hIcon );
} }
EndPaint( wndPtr->hwndSelf, &ps ); EndPaint( hwnd, &ps );
} }
return 0; return 0;
} }
case WM_SYNCPAINT: case WM_SYNCPAINT:
RedrawWindow ( wndPtr->hwndSelf, NULL, 0, RDW_ERASENOW | RDW_ERASE | RDW_ALLCHILDREN ); RedrawWindow ( hwnd, NULL, 0, RDW_ERASENOW | RDW_ERASE | RDW_ALLCHILDREN );
return 0; return 0;
case WM_SETREDRAW: case WM_SETREDRAW:
DEFWND_SetRedraw( wndPtr, wParam ); DEFWND_SetRedraw( hwnd, wParam );
return 0; return 0;
case WM_CLOSE: case WM_CLOSE:
DestroyWindow( wndPtr->hwndSelf ); DestroyWindow( hwnd );
return 0; return 0;
case WM_MOUSEACTIVATE: case WM_MOUSEACTIVATE:
if (wndPtr->dwStyle & WS_CHILD) if (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD)
{ {
LONG ret = pSendMessage( wndPtr->parent->hwndSelf, LONG ret = SendMessageW( GetParent(hwnd), WM_MOUSEACTIVATE, wParam, lParam );
WM_MOUSEACTIVATE, wParam, lParam );
if (ret) return ret; if (ret) return ret;
} }
@ -440,17 +440,13 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
/* The default action in Windows is to set the keyboard focus to /* The default action in Windows is to set the keyboard focus to
* the window, if it's being activated and not minimized */ * the window, if it's being activated and not minimized */
if (LOWORD(wParam) != WA_INACTIVE) { if (LOWORD(wParam) != WA_INACTIVE) {
if (!(wndPtr->dwStyle & WS_MINIMIZE)) if (!IsIconic(hwnd)) SetFocus(hwnd);
SetFocus(wndPtr->hwndSelf);
} }
break; break;
case WM_MOUSEWHEEL: case WM_MOUSEWHEEL:
if (wndPtr->dwStyle & WS_CHILD) if (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD)
{ return SendMessageW( GetParent(hwnd), WM_MOUSEWHEEL, wParam, lParam );
return pSendMessage( wndPtr->parent->hwndSelf,
WM_MOUSEWHEEL, wParam, lParam );
}
break; break;
case WM_ERASEBKGND: case WM_ERASEBKGND:
@ -458,13 +454,13 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
{ {
RECT rect; RECT rect;
HDC hdc = (HDC)wParam; HDC hdc = (HDC)wParam;
HBRUSH hbr = GetClassLongW( wndPtr->hwndSelf, GCL_HBRBACKGROUND ); HBRUSH hbr = GetClassLongW( hwnd, GCL_HBRBACKGROUND );
if (!hbr) return 0; if (!hbr) return 0;
if (GetClassLongW( wndPtr->hwndSelf, GCL_STYLE ) & CS_PARENTDC) if (GetClassLongW( hwnd, GCL_STYLE ) & CS_PARENTDC)
{ {
/* can't use GetClipBox with a parent DC or we fill the whole parent */ /* can't use GetClipBox with a parent DC or we fill the whole parent */
GetClientRect( wndPtr->hwndSelf, &rect ); GetClientRect( hwnd, &rect );
DPtoLP( hdc, (LPPOINT)&rect, 2 ); DPtoLP( hdc, (LPPOINT)&rect, 2 );
} }
else GetClipBox( hdc, &rect ); else GetClipBox( hdc, &rect );
@ -488,24 +484,23 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
return (LRESULT)DEFWND_ControlColor( (HDC)wParam, HIWORD(lParam) ); return (LRESULT)DEFWND_ControlColor( (HDC)wParam, HIWORD(lParam) );
case WM_SETCURSOR: case WM_SETCURSOR:
if (wndPtr->dwStyle & WS_CHILD) if (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD)
{ {
/* with the exception of the border around a resizable wnd, /* with the exception of the border around a resizable wnd,
* give the parent first chance to set the cursor */ * give the parent first chance to set the cursor */
if ((LOWORD(lParam) < HTSIZEFIRST) || (LOWORD(lParam) > HTSIZELAST)) if ((LOWORD(lParam) < HTSIZEFIRST) || (LOWORD(lParam) > HTSIZELAST))
{ {
if (pSendMessage(wndPtr->parent->hwndSelf, WM_SETCURSOR, wParam, lParam)) if (SendMessageW(GetParent(hwnd), WM_SETCURSOR, wParam, lParam)) return TRUE;
return TRUE;
} }
} }
return NC_HandleSetCursor( wndPtr->hwndSelf, wParam, lParam ); return NC_HandleSetCursor( hwnd, wParam, lParam );
case WM_SYSCOMMAND: case WM_SYSCOMMAND:
{ {
POINT pt; POINT pt;
pt.x = SLOWORD(lParam); pt.x = SLOWORD(lParam);
pt.y = SHIWORD(lParam); pt.y = SHIWORD(lParam);
return NC_HandleSysCommand( wndPtr->hwndSelf, wParam, pt ); return NC_HandleSysCommand( hwnd, wParam, pt );
} }
case WM_KEYDOWN: case WM_KEYDOWN:
@ -525,18 +520,16 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
if( wParam == VK_F4 ) /* try to close the window */ if( wParam == VK_F4 ) /* try to close the window */
{ {
HWND hWnd = WIN_GetTopParent( wndPtr->hwndSelf ); HWND top = WIN_GetTopParent( hwnd );
wndPtr = WIN_FindWndPtr( hWnd ); if (!(GetClassLongW( top, GCL_STYLE ) & CS_NOCLOSE))
if( wndPtr && !(wndPtr->clsStyle & CS_NOCLOSE) ) PostMessageW( top, WM_SYSCOMMAND, SC_CLOSE, 0 );
pPostMessage( hWnd, WM_SYSCOMMAND, SC_CLOSE, 0 );
WIN_ReleaseWndPtr(wndPtr);
} }
} }
else if( wParam == VK_F10 ) else if( wParam == VK_F10 )
iF10Key = 1; iF10Key = 1;
else else
if( wParam == VK_ESCAPE && (GetKeyState(VK_SHIFT) & 0x8000)) if( wParam == VK_ESCAPE && (GetKeyState(VK_SHIFT) & 0x8000))
pSendMessage( wndPtr->hwndSelf, WM_SYSCOMMAND, SC_KEYMENU, VK_SPACE ); SendMessageW( hwnd, WM_SYSCOMMAND, SC_KEYMENU, VK_SPACE );
break; break;
case WM_KEYUP: case WM_KEYUP:
@ -544,42 +537,44 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
/* Press and release F10 or ALT */ /* Press and release F10 or ALT */
if (((wParam == VK_MENU) && iMenuSysKey) || if (((wParam == VK_MENU) && iMenuSysKey) ||
((wParam == VK_F10) && iF10Key)) ((wParam == VK_F10) && iF10Key))
pSendMessage( WIN_GetTopParent(wndPtr->hwndSelf), SendMessageW( WIN_GetTopParent(hwnd), WM_SYSCOMMAND, SC_KEYMENU, 0L );
WM_SYSCOMMAND, SC_KEYMENU, 0L );
iMenuSysKey = iF10Key = 0; iMenuSysKey = iF10Key = 0;
break; break;
case WM_SYSCHAR: case WM_SYSCHAR:
iMenuSysKey = 0; iMenuSysKey = 0;
if (wParam == VK_RETURN && (wndPtr->dwStyle & WS_MINIMIZE)) if (wParam == VK_RETURN && IsIconic(hwnd))
{ {
pPostMessage( wndPtr->hwndSelf, WM_SYSCOMMAND, SC_RESTORE, 0L ); PostMessageW( hwnd, WM_SYSCOMMAND, SC_RESTORE, 0L );
break; break;
} }
if ((HIWORD(lParam) & KEYDATA_ALT) && wParam) if ((HIWORD(lParam) & KEYDATA_ALT) && wParam)
{ {
if (wParam == VK_TAB || wParam == VK_ESCAPE) break; if (wParam == VK_TAB || wParam == VK_ESCAPE) break;
if (wParam == VK_SPACE && (wndPtr->dwStyle & WS_CHILD)) if (wParam == VK_SPACE && (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD))
pSendMessage( wndPtr->parent->hwndSelf, msg, wParam, lParam ); SendMessageW( GetParent(hwnd), msg, wParam, lParam );
else else
pSendMessage( wndPtr->hwndSelf, WM_SYSCOMMAND, SC_KEYMENU, wParam ); SendMessageW( hwnd, WM_SYSCOMMAND, SC_KEYMENU, wParam );
} }
else /* check for Ctrl-Esc */ else /* check for Ctrl-Esc */
if (wParam != VK_ESCAPE) MessageBeep(0); if (wParam != VK_ESCAPE) MessageBeep(0);
break; break;
case WM_SHOWWINDOW: case WM_SHOWWINDOW:
{
LONG style = GetWindowLongW( hwnd, GWL_STYLE );
if (!lParam) return 0; /* sent from ShowWindow */ if (!lParam) return 0; /* sent from ShowWindow */
if (!(wndPtr->dwStyle & WS_POPUP) || !wndPtr->owner) return 0; if (!(style & WS_POPUP)) return 0;
if ((wndPtr->dwStyle & WS_VISIBLE) && wParam) return 0; if ((style & WS_VISIBLE) && wParam) return 0;
else if (!(wndPtr->dwStyle & WS_VISIBLE) && !wParam) return 0; if (!(style & WS_VISIBLE) && !wParam) return 0;
ShowWindow( wndPtr->hwndSelf, wParam ? SW_SHOWNOACTIVATE : SW_HIDE ); if (!GetWindow( hwnd, GW_OWNER )) return 0;
ShowWindow( hwnd, wParam ? SW_SHOWNOACTIVATE : SW_HIDE );
break; break;
}
case WM_CANCELMODE: case WM_CANCELMODE:
if (wndPtr->parent == WIN_GetDesktop()) EndMenu(); if (!(GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD)) EndMenu();
if (GetCapture() == wndPtr->hwndSelf) ReleaseCapture(); if (GetCapture() == hwnd) ReleaseCapture();
WIN_ReleaseDesktop();
break; break;
case WM_VKEYTOITEM: case WM_VKEYTOITEM:
@ -590,27 +585,32 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
return DRAG_FILE; return DRAG_FILE;
case WM_QUERYDROPOBJECT: case WM_QUERYDROPOBJECT:
if (wndPtr->dwExStyle & WS_EX_ACCEPTFILES) return 1; return (GetWindowLongA( hwnd, GWL_EXSTYLE ) & WS_EX_ACCEPTFILES) != 0;
break;
case WM_QUERYDRAGICON: case WM_QUERYDRAGICON:
{ {
UINT len; UINT len;
HICON hIcon = GetClassLongW( wndPtr->hwndSelf, GCL_HICON ); HICON hIcon = GetClassLongW( hwnd, GCL_HICON );
HINSTANCE instance = GetWindowLongW( hwnd, GWL_HINSTANCE );
if (hIcon) return hIcon; if (hIcon) return hIcon;
for(len=1; len<64; len++) for(len=1; len<64; len++)
if((hIcon = LoadIconW(wndPtr->hInstance, MAKEINTRESOURCEW(len)))) if((hIcon = LoadIconW(instance, MAKEINTRESOURCEW(len))))
return (LRESULT)hIcon; return (LRESULT)hIcon;
return (LRESULT)LoadIconW(0, IDI_APPLICATIONW); return (LRESULT)LoadIconW(0, IDI_APPLICATIONW);
} }
break; break;
case WM_ISACTIVEICON: case WM_ISACTIVEICON:
return ((wndPtr->flags & WIN_NCACTIVATED) != 0); {
WND *wndPtr = WIN_FindWndPtr( hwnd );
BOOL ret = (wndPtr->flags & WIN_NCACTIVATED) != 0;
WIN_ReleaseWndPtr( wndPtr );
return ret;
}
case WM_NOTIFYFORMAT: case WM_NOTIFYFORMAT:
if (IsWindowUnicode(wndPtr->hwndSelf)) return NFR_UNICODE; if (IsWindowUnicode(hwnd)) return NFR_UNICODE;
else return NFR_ANSI; else return NFR_ANSI;
case WM_QUERYOPEN: case WM_QUERYOPEN:
@ -619,14 +619,14 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
case WM_SETICON: case WM_SETICON:
if (USER_Driver.pSetWindowIcon) if (USER_Driver.pSetWindowIcon)
return USER_Driver.pSetWindowIcon( wndPtr->hwndSelf, lParam, (wParam != ICON_SMALL) ); return USER_Driver.pSetWindowIcon( hwnd, lParam, (wParam != ICON_SMALL) );
else else
{ {
int index = (wParam != ICON_SMALL) ? GCL_HICON : GCL_HICONSM; int index = (wParam != ICON_SMALL) ? GCL_HICON : GCL_HICONSM;
HICON hOldIcon = GetClassLongW(wndPtr->hwndSelf, index); HICON hOldIcon = GetClassLongW(hwnd, index);
SetClassLongW(wndPtr->hwndSelf, index, lParam); SetClassLongW(hwnd, index, lParam);
SetWindowPos(wndPtr->hwndSelf, 0, 0, 0, 0, 0, SWP_FRAMECHANGED SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED
| SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE
| SWP_NOZORDER); | SWP_NOZORDER);
return hOldIcon; return hOldIcon;
@ -635,11 +635,11 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
case WM_GETICON: case WM_GETICON:
{ {
int index = (wParam != ICON_SMALL) ? GCL_HICON : GCL_HICONSM; int index = (wParam != ICON_SMALL) ? GCL_HICON : GCL_HICONSM;
return GetClassLongW(wndPtr->hwndSelf, index); return GetClassLongW(hwnd, index);
} }
case WM_HELP: case WM_HELP:
pSendMessage( wndPtr->parent->hwndSelf, msg, wParam, lParam ); SendMessageW( GetParent(hwnd), msg, wParam, lParam );
break; break;
} }
@ -654,10 +654,9 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
LRESULT WINAPI DefWindowProc16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam, LRESULT WINAPI DefWindowProc16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam,
LPARAM lParam ) LPARAM lParam )
{ {
WND * wndPtr = WIN_FindWndPtr( hwnd );
LRESULT result = 0; LRESULT result = 0;
if (!wndPtr) return 0; if (!IsWindow( hwnd )) return 0;
SPY_EnterMessage( SPY_DEFWNDPROC16, hwnd, msg, wParam, lParam ); SPY_EnterMessage( SPY_DEFWNDPROC16, hwnd, msg, wParam, lParam );
switch(msg) switch(msg)
@ -668,7 +667,7 @@ LRESULT WINAPI DefWindowProc16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam,
/* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP) /* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
* may have child window IDs instead of window name */ * may have child window IDs instead of window name */
if (HIWORD(cs->lpszName)) if (HIWORD(cs->lpszName))
DEFWND_SetTextA( wndPtr, MapSL(cs->lpszName) ); DEFWND_SetTextA( hwnd, MapSL(cs->lpszName) );
result = 1; result = 1;
} }
break; break;
@ -689,39 +688,20 @@ LRESULT WINAPI DefWindowProc16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam,
case WM_WINDOWPOSCHANGED: case WM_WINDOWPOSCHANGED:
{ {
WINDOWPOS16 * winPos = MapSL(lParam); WINDOWPOS16 * winPos = MapSL(lParam);
DEFWND_HandleWindowPosChanged( wndPtr, winPos->flags ); DEFWND_HandleWindowPosChanged( hwnd, winPos->flags );
} }
break; break;
case WM_GETTEXTLENGTH:
if (wndPtr->text)
result = WideCharToMultiByte( CP_ACP, 0, wndPtr->text, strlenW(wndPtr->text),
NULL, 0, NULL, NULL );
break;
case WM_GETTEXT: case WM_GETTEXT:
if (wParam && wndPtr->text)
{
LPSTR dest = MapSL(lParam);
if (!WideCharToMultiByte( CP_ACP, 0, wndPtr->text, -1, dest, wParam, NULL, NULL ))
dest[wParam-1] = 0;
result = strlen(dest);
}
break;
case WM_SETTEXT: case WM_SETTEXT:
DEFWND_SetTextA( wndPtr, MapSL(lParam) ); result = DefWindowProcA( hwnd, msg, wParam, (LPARAM)MapSL(lParam) );
if( (wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION )
NC_HandleNCPaint( hwnd , (HRGN)1 );
result = 1; /* success. FIXME: check text length */
break; break;
default: default:
result = DEFWND_DefWinProc( wndPtr, msg, wParam, lParam, FALSE ); result = DefWindowProcA( hwnd, msg, wParam, lParam );
break; break;
} }
WIN_ReleaseWndPtr(wndPtr);
SPY_ExitMessage( SPY_RESULT_DEFWND16, hwnd, msg, result, wParam, lParam ); SPY_ExitMessage( SPY_RESULT_DEFWND16, hwnd, msg, result, wParam, lParam );
return result; return result;
} }
@ -731,13 +711,11 @@ LRESULT WINAPI DefWindowProc16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam,
* DefWindowProcA (USER32.@) * DefWindowProcA (USER32.@)
* *
*/ */
LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam, LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
LPARAM lParam )
{ {
WND * wndPtr = WIN_FindWndPtr( hwnd );
LRESULT result = 0; LRESULT result = 0;
if (!wndPtr) return 0; if (!IsWindow( hwnd )) return 0;
SPY_EnterMessage( SPY_DEFWNDPROC, hwnd, msg, wParam, lParam ); SPY_EnterMessage( SPY_DEFWNDPROC, hwnd, msg, wParam, lParam );
switch(msg) switch(msg)
@ -748,7 +726,7 @@ LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam,
/* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP) /* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
* may have child window IDs instead of window name */ * may have child window IDs instead of window name */
if (HIWORD(cs->lpszName)) if (HIWORD(cs->lpszName))
DEFWND_SetTextA( wndPtr, cs->lpszName ); DEFWND_SetTextA( hwnd, cs->lpszName );
result = 1; result = 1;
} }
break; break;
@ -764,29 +742,37 @@ LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam,
case WM_WINDOWPOSCHANGED: case WM_WINDOWPOSCHANGED:
{ {
WINDOWPOS * winPos = (WINDOWPOS *)lParam; WINDOWPOS * winPos = (WINDOWPOS *)lParam;
DEFWND_HandleWindowPosChanged( wndPtr, winPos->flags ); DEFWND_HandleWindowPosChanged( hwnd, winPos->flags );
} }
break; break;
case WM_GETTEXTLENGTH: case WM_GETTEXTLENGTH:
if (wndPtr->text) {
WND *wndPtr = WIN_FindWndPtr( hwnd );
if (wndPtr && wndPtr->text)
result = WideCharToMultiByte( CP_ACP, 0, wndPtr->text, strlenW(wndPtr->text), result = WideCharToMultiByte( CP_ACP, 0, wndPtr->text, strlenW(wndPtr->text),
NULL, 0, NULL, NULL ); NULL, 0, NULL, NULL );
WIN_ReleaseWndPtr( wndPtr );
}
break; break;
case WM_GETTEXT: case WM_GETTEXT:
if (wParam && wndPtr->text)
{ {
WND *wndPtr = WIN_FindWndPtr( hwnd );
if (wParam && wndPtr && wndPtr->text)
{
LPSTR dest = (LPSTR)lParam;
if (!WideCharToMultiByte( CP_ACP, 0, wndPtr->text, -1, if (!WideCharToMultiByte( CP_ACP, 0, wndPtr->text, -1,
(LPSTR)lParam, wParam, NULL, NULL )) dest, wParam, NULL, NULL )) dest[wParam-1] = 0;
((LPSTR)lParam)[wParam-1] = 0; result = strlen( dest );
result = (LRESULT)strlen( (LPSTR)lParam ); }
WIN_ReleaseWndPtr( wndPtr );
} }
break; break;
case WM_SETTEXT: case WM_SETTEXT:
DEFWND_SetTextA( wndPtr, (LPCSTR)lParam ); DEFWND_SetTextA( hwnd, (LPCSTR)lParam );
if( (wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION ) if( (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CAPTION) == WS_CAPTION )
NC_HandleNCPaint( hwnd , (HRGN)1 ); /* Repaint caption */ NC_HandleNCPaint( hwnd , (HRGN)1 ); /* Repaint caption */
result = 1; /* success. FIXME: check text length */ result = 1; /* success. FIXME: check text length */
break; break;
@ -832,11 +818,10 @@ LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam,
break; break;
default: default:
result = DEFWND_DefWinProc( wndPtr, msg, wParam, lParam, FALSE ); result = DEFWND_DefWinProc( hwnd, msg, wParam, lParam );
break; break;
} }
WIN_ReleaseWndPtr(wndPtr);
SPY_ExitMessage( SPY_RESULT_DEFWND, hwnd, msg, result, wParam, lParam ); SPY_ExitMessage( SPY_RESULT_DEFWND, hwnd, msg, result, wParam, lParam );
return result; return result;
} }
@ -857,10 +842,9 @@ LRESULT WINAPI DefWindowProcW(
WPARAM wParam, /* [in] first message parameter */ WPARAM wParam, /* [in] first message parameter */
LPARAM lParam ) /* [in] second message parameter */ LPARAM lParam ) /* [in] second message parameter */
{ {
WND * wndPtr = WIN_FindWndPtr( hwnd );
LRESULT result = 0; LRESULT result = 0;
if (!wndPtr) return 0; if (!IsWindow( hwnd )) return 0;
SPY_EnterMessage( SPY_DEFWNDPROC, hwnd, msg, wParam, lParam ); SPY_EnterMessage( SPY_DEFWNDPROC, hwnd, msg, wParam, lParam );
switch(msg) switch(msg)
@ -871,7 +855,7 @@ LRESULT WINAPI DefWindowProcW(
/* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP) /* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
* may have child window IDs instead of window name */ * may have child window IDs instead of window name */
if (HIWORD(cs->lpszName)) if (HIWORD(cs->lpszName))
DEFWND_SetTextW( wndPtr, cs->lpszName ); DEFWND_SetTextW( hwnd, cs->lpszName );
result = 1; result = 1;
} }
break; break;
@ -887,25 +871,34 @@ LRESULT WINAPI DefWindowProcW(
case WM_WINDOWPOSCHANGED: case WM_WINDOWPOSCHANGED:
{ {
WINDOWPOS * winPos = (WINDOWPOS *)lParam; WINDOWPOS * winPos = (WINDOWPOS *)lParam;
DEFWND_HandleWindowPosChanged( wndPtr, winPos->flags ); DEFWND_HandleWindowPosChanged( hwnd, winPos->flags );
} }
break; break;
case WM_GETTEXTLENGTH: case WM_GETTEXTLENGTH:
if (wndPtr->text) result = (LRESULT)strlenW(wndPtr->text); {
WND *wndPtr = WIN_FindWndPtr( hwnd );
if (wndPtr && wndPtr->text) result = (LRESULT)strlenW(wndPtr->text);
WIN_ReleaseWndPtr( wndPtr );
}
break; break;
case WM_GETTEXT: case WM_GETTEXT:
if (wParam && wndPtr->text)
{ {
lstrcpynW( (LPWSTR)lParam, wndPtr->text, wParam ); WND *wndPtr = WIN_FindWndPtr( hwnd );
result = strlenW( (LPWSTR)lParam ); if (wParam && wndPtr && wndPtr->text)
{
LPWSTR dest = (LPWSTR)lParam;
lstrcpynW( dest, wndPtr->text, wParam );
result = strlenW( dest );
}
WIN_ReleaseWndPtr( wndPtr );
} }
break; break;
case WM_SETTEXT: case WM_SETTEXT:
DEFWND_SetTextW( wndPtr, (LPCWSTR)lParam ); DEFWND_SetTextW( hwnd, (LPCWSTR)lParam );
if( (wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION ) if( (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CAPTION) == WS_CAPTION )
NC_HandleNCPaint( hwnd , (HRGN)1 ); /* Repaint caption */ NC_HandleNCPaint( hwnd , (HRGN)1 ); /* Repaint caption */
result = 1; /* success. FIXME: check text length */ result = 1; /* success. FIXME: check text length */
break; break;
@ -925,10 +918,9 @@ LRESULT WINAPI DefWindowProcW(
break; break;
default: default:
result = DEFWND_DefWinProc( wndPtr, msg, wParam, lParam, TRUE ); result = DEFWND_DefWinProc( hwnd, msg, wParam, lParam );
break; break;
} }
WIN_ReleaseWndPtr(wndPtr);
SPY_ExitMessage( SPY_RESULT_DEFWND, hwnd, msg, result, wParam, lParam ); SPY_ExitMessage( SPY_RESULT_DEFWND, hwnd, msg, result, wParam, lParam );
return result; return result;
} }

File diff suppressed because it is too large Load Diff

View File

@ -122,21 +122,18 @@ static void queue_hardware_message( MSG *msg, ULONG_PTR extra_info, enum message
*/ */
static void MSG_SendParentNotify( HWND hwnd, WORD event, WORD idChild, POINT pt ) static void MSG_SendParentNotify( HWND hwnd, WORD event, WORD idChild, POINT pt )
{ {
WND *tmpWnd = WIN_FindWndPtr(hwnd);
/* pt has to be in the client coordinates of the parent window */ /* pt has to be in the client coordinates of the parent window */
MapWindowPoints( 0, tmpWnd->hwndSelf, &pt, 1 ); MapWindowPoints( 0, hwnd, &pt, 1 );
while (tmpWnd) for (;;)
{ {
if (!(tmpWnd->dwStyle & WS_CHILD) || (tmpWnd->dwExStyle & WS_EX_NOPARENTNOTIFY)) HWND parent;
{
WIN_ReleaseWndPtr(tmpWnd); if (!(GetWindowLongA( hwnd, GWL_STYLE ) & WS_CHILD)) break;
break; if (GetWindowLongA( hwnd, GWL_EXSTYLE ) & WS_EX_NOPARENTNOTIFY) break;
} if (!(parent = GetParent(hwnd))) break;
pt.x += tmpWnd->rectClient.left; MapWindowPoints( hwnd, parent, &pt, 1 );
pt.y += tmpWnd->rectClient.top; hwnd = parent;
WIN_UpdateWndPtr(&tmpWnd,tmpWnd->parent); SendMessageA( hwnd, WM_PARENTNOTIFY,
SendMessageA( tmpWnd->hwndSelf, WM_PARENTNOTIFY,
MAKEWPARAM( event, idChild ), MAKELPARAM( pt.x, pt.y ) ); MAKEWPARAM( event, idChild ), MAKELPARAM( pt.x, pt.y ) );
} }
} }

View File

@ -324,7 +324,7 @@ HDC WINAPI BeginPaint( HWND hwnd, PAINTSTRUCT *lps )
WND *wndPtr = WIN_FindWndPtr( hwnd ); WND *wndPtr = WIN_FindWndPtr( hwnd );
if (!wndPtr) return 0; if (!wndPtr) return 0;
bIcon = (wndPtr->dwStyle & WS_MINIMIZE && GetClassWord(wndPtr->hwndSelf, GCW_HICON)); bIcon = (wndPtr->dwStyle & WS_MINIMIZE && GetClassLongA(hwnd, GCL_HICON));
wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT; wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
@ -756,7 +756,7 @@ static HRGN RDW_Paint( WND* wndPtr, HRGN hrgn, UINT flags, UINT ex )
*/ */
HDC hDC; HDC hDC;
HWND hWnd = wndPtr->hwndSelf; HWND hWnd = wndPtr->hwndSelf;
BOOL bIcon = ((wndPtr->dwStyle & WS_MINIMIZE) && GetClassWord(wndPtr->hwndSelf, GCW_HICON)); BOOL bIcon = ((wndPtr->dwStyle & WS_MINIMIZE) && GetClassLongA(hWnd, GCL_HICON));
/* Erase/update the window itself ... */ /* Erase/update the window itself ... */
@ -814,20 +814,18 @@ static HRGN RDW_Paint( WND* wndPtr, HRGN hrgn, UINT flags, UINT ex )
if( wndPtr->child && !(flags & RDW_NOCHILDREN) && !(wndPtr->dwStyle & WS_MINIMIZE) if( wndPtr->child && !(flags & RDW_NOCHILDREN) && !(wndPtr->dwStyle & WS_MINIMIZE)
&& ((flags & RDW_ALLCHILDREN) || !(wndPtr->dwStyle & WS_CLIPCHILDREN)) ) && ((flags & RDW_ALLCHILDREN) || !(wndPtr->dwStyle & WS_CLIPCHILDREN)) )
{ {
WND** list, **ppWnd; HWND *list, *phwnd;
if( (list = WIN_BuildWinArray( wndPtr, 0, NULL )) ) if( (list = WIN_BuildWinArray( wndPtr->hwndSelf )) )
{ {
wndPtr = NULL; for (phwnd = list; *phwnd; phwnd++)
for (ppWnd = list; *ppWnd; ppWnd++)
{ {
WIN_UpdateWndPtr(&wndPtr,*ppWnd); if (!(wndPtr = WIN_FindWndPtr( *phwnd ))) continue;
if (!IsWindow(wndPtr->hwndSelf)) continue;
if ( (wndPtr->dwStyle & WS_VISIBLE) && if ( (wndPtr->dwStyle & WS_VISIBLE) &&
(wndPtr->hrgnUpdate || (wndPtr->flags & WIN_INTERNAL_PAINT)) ) (wndPtr->hrgnUpdate || (wndPtr->flags & WIN_INTERNAL_PAINT)) )
hrgn = RDW_Paint( wndPtr, hrgn, flags, ex ); hrgn = RDW_Paint( wndPtr, hrgn, flags, ex );
}
WIN_ReleaseWndPtr(wndPtr); WIN_ReleaseWndPtr(wndPtr);
}
WIN_ReleaseWinArray(list); WIN_ReleaseWinArray(list);
} }
} }

View File

@ -220,38 +220,32 @@ BOOL WINAPI ExitWindowsEx( UINT flags, DWORD reserved )
{ {
int i; int i;
BOOL result; BOOL result;
WND **list, **ppWnd; HWND *list, *phwnd;
/* We have to build a list of all windows first, as in EnumWindows */ /* We have to build a list of all windows first, as in EnumWindows */
if (!(list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL ))) if (!(list = WIN_BuildWinArray( GetDesktopWindow() ))) return FALSE;
{
WIN_ReleaseDesktop();
return FALSE;
}
/* Send a WM_QUERYENDSESSION message to every window */ /* Send a WM_QUERYENDSESSION message to every window */
for (ppWnd = list, i = 0; *ppWnd; ppWnd++, i++) for (i = 0; list[i]; i++)
{ {
/* Make sure that the window still exists */ /* Make sure that the window still exists */
if (!IsWindow( (*ppWnd)->hwndSelf )) continue; if (!IsWindow( list[i] )) continue;
if (!SendMessageW( (*ppWnd)->hwndSelf, WM_QUERYENDSESSION, 0, 0 )) if (!SendMessageW( list[i], WM_QUERYENDSESSION, 0, 0 )) break;
break;
} }
result = !(*ppWnd); result = !list[i];
/* Now notify all windows that got a WM_QUERYENDSESSION of the result */ /* Now notify all windows that got a WM_QUERYENDSESSION of the result */
for (ppWnd = list; i > 0; i--, ppWnd++) for (phwnd = list; i > 0; i--, phwnd++)
{ {
if (!IsWindow( (*ppWnd)->hwndSelf )) continue; if (!IsWindow( *phwnd )) continue;
SendMessageW( (*ppWnd)->hwndSelf, WM_ENDSESSION, result, 0 ); SendMessageW( *phwnd, WM_ENDSESSION, result, 0 );
} }
WIN_ReleaseWinArray(list); WIN_ReleaseWinArray(list);
if (result) ExitKernel16(); if (result) ExitKernel16();
WIN_ReleaseDesktop();
return FALSE; return FALSE;
} }

View File

@ -19,6 +19,7 @@
#include "hook.h" #include "hook.h"
#include "message.h" #include "message.h"
#include "queue.h" #include "queue.h"
#include "task.h"
#include "winpos.h" #include "winpos.h"
#include "winerror.h" #include "winerror.h"
#include "stackframe.h" #include "stackframe.h"
@ -1096,7 +1097,8 @@ HWND WINAPI CreateWindowExW( DWORD exStyle, LPCWSTR className,
static void WIN_SendDestroyMsg( WND* pWnd ) static void WIN_SendDestroyMsg( WND* pWnd )
{ {
if( CARET_GetHwnd() == pWnd->hwndSelf ) DestroyCaret(); if( CARET_GetHwnd() == pWnd->hwndSelf ) DestroyCaret();
USER_Driver.pResetSelectionOwner( pWnd, TRUE ); if (USER_Driver.pResetSelectionOwner)
USER_Driver.pResetSelectionOwner( pWnd->hwndSelf, TRUE );
/* /*
* Send the WM_DESTROY to the window. * Send the WM_DESTROY to the window.
@ -1261,7 +1263,8 @@ BOOL WINAPI DestroyWindow( HWND hwnd )
} }
} }
USER_Driver.pResetSelectionOwner( wndPtr, FALSE ); /* before the window is unmapped */ if (USER_Driver.pResetSelectionOwner)
USER_Driver.pResetSelectionOwner( hwnd, FALSE ); /* before the window is unmapped */
/* Hide the window */ /* Hide the window */
@ -2544,49 +2547,52 @@ HWND16 WINAPI GetNextWindow16( HWND16 hwnd, WORD flag )
BOOL WIN_InternalShowOwnedPopups( HWND owner, BOOL fShow, BOOL unmanagedOnly ) BOOL WIN_InternalShowOwnedPopups( HWND owner, BOOL fShow, BOOL unmanagedOnly )
{ {
INT totalChild=0, count=0; int count = 0;
HWND *win_array = WIN_BuildWinArray( GetDesktopWindow() );
WND **pWnd = WIN_BuildWinArray(WIN_GetDesktop(), 0, &totalChild); if (!win_array) return TRUE;
if (!pWnd) return TRUE;
/* /*
* Show windows Lowest first, Highest last to preserve Z-Order * Show windows Lowest first, Highest last to preserve Z-Order
*/ */
for (count = totalChild-1 ; count >=0; count--) while (win_array[count]) count++;
while (--count >= 0)
{ {
if (pWnd[count]->owner && (pWnd[count]->owner->hwndSelf == owner) && (pWnd[count]->dwStyle & WS_POPUP)) WND *pWnd = WIN_FindWndPtr( win_array[count] );
if (!pWnd) continue;
if (pWnd->owner && (pWnd->owner->hwndSelf == owner) && (pWnd->dwStyle & WS_POPUP))
{ {
if (fShow) if (fShow)
{ {
/* check in window was flagged for showing in previous WIN_InternalShowOwnedPopups call */ /* check in window was flagged for showing in previous WIN_InternalShowOwnedPopups call */
if (pWnd[count]->flags & WIN_NEEDS_INTERNALSOP) if (pWnd->flags & WIN_NEEDS_INTERNALSOP)
{ {
/* /*
* Call ShowWindow directly because an application can intercept WM_SHOWWINDOW messages * Call ShowWindow directly because an application can intercept WM_SHOWWINDOW messages
*/ */
ShowWindow(pWnd[count]->hwndSelf,SW_SHOW); ShowWindow(pWnd->hwndSelf,SW_SHOW);
pWnd[count]->flags &= ~WIN_NEEDS_INTERNALSOP; /* remove the flag */ pWnd->flags &= ~WIN_NEEDS_INTERNALSOP; /* remove the flag */
} }
} }
else else
{ {
if ( IsWindowVisible(pWnd[count]->hwndSelf) && /* hide only if window is visible */ if ( IsWindowVisible(pWnd->hwndSelf) && /* hide only if window is visible */
!( pWnd[count]->flags & WIN_NEEDS_INTERNALSOP ) && /* don't hide if previous call already did it */ !( pWnd->flags & WIN_NEEDS_INTERNALSOP ) && /* don't hide if previous call already did it */
!( unmanagedOnly && (pWnd[count]->dwExStyle & WS_EX_MANAGED) ) ) /* don't hide managed windows if unmanagedOnly is TRUE */ !( unmanagedOnly && (pWnd->dwExStyle & WS_EX_MANAGED) ) ) /* don't hide managed windows if unmanagedOnly is TRUE */
{ {
/* /*
* Call ShowWindow directly because an application can intercept WM_SHOWWINDOW messages * Call ShowWindow directly because an application can intercept WM_SHOWWINDOW messages
*/ */
ShowWindow(pWnd[count]->hwndSelf,SW_HIDE); ShowWindow(pWnd->hwndSelf,SW_HIDE);
/* flag the window for showing on next WIN_InternalShowOwnedPopups call */ /* flag the window for showing on next WIN_InternalShowOwnedPopups call */
pWnd[count]->flags |= WIN_NEEDS_INTERNALSOP; pWnd->flags |= WIN_NEEDS_INTERNALSOP;
} }
} }
} }
WIN_ReleaseWndPtr( pWnd );
} }
WIN_ReleaseDesktop(); WIN_ReleaseWinArray( win_array );
WIN_ReleaseWinArray(pWnd);
return TRUE; return TRUE;
} }
@ -2605,45 +2611,48 @@ void WINAPI ShowOwnedPopups16( HWND16 owner, BOOL16 fShow )
*/ */
BOOL WINAPI ShowOwnedPopups( HWND owner, BOOL fShow ) BOOL WINAPI ShowOwnedPopups( HWND owner, BOOL fShow )
{ {
UINT totalChild=0, count=0; int count = 0;
WND **pWnd = WIN_BuildWinArray(WIN_GetDesktop(), 0, &totalChild); HWND *win_array = WIN_BuildWinArray(GetDesktopWindow());
if (!pWnd) return TRUE; if (!win_array) return TRUE;
for (; count < totalChild; count++) while (win_array[count]) count++;
while (--count >= 0)
{ {
if (pWnd[count]->owner && (pWnd[count]->owner->hwndSelf == owner) && (pWnd[count]->dwStyle & WS_POPUP)) WND *pWnd = WIN_FindWndPtr( win_array[count] );
if (!pWnd) continue;
if (pWnd->owner && (pWnd->owner->hwndSelf == owner) && (pWnd->dwStyle & WS_POPUP))
{ {
if (fShow) if (fShow)
{ {
if (pWnd[count]->flags & WIN_NEEDS_SHOW_OWNEDPOPUP) if (pWnd->flags & WIN_NEEDS_SHOW_OWNEDPOPUP)
{ {
/* /* In Windows, ShowOwnedPopups(TRUE) generates
* In Windows, ShowOwnedPopups(TRUE) generates WM_SHOWWINDOW messages with SW_PARENTOPENING, * WM_SHOWWINDOW messages with SW_PARENTOPENING,
* regardless of the state of the owner * regardless of the state of the owner
*/ */
SendMessageA(pWnd[count]->hwndSelf, WM_SHOWWINDOW, SW_SHOW, SW_PARENTOPENING); SendMessageA(pWnd->hwndSelf, WM_SHOWWINDOW, SW_SHOW, SW_PARENTOPENING);
pWnd[count]->flags &= ~WIN_NEEDS_SHOW_OWNEDPOPUP; pWnd->flags &= ~WIN_NEEDS_SHOW_OWNEDPOPUP;
} }
} }
else else
{ {
if (IsWindowVisible(pWnd[count]->hwndSelf)) if (IsWindowVisible(pWnd->hwndSelf))
{ {
/* /* In Windows, ShowOwnedPopups(FALSE) generates
* In Windows, ShowOwnedPopups(FALSE) generates WM_SHOWWINDOW messages with SW_PARENTCLOSING, * WM_SHOWWINDOW messages with SW_PARENTCLOSING,
* regardless of the state of the owner * regardless of the state of the owner
*/ */
SendMessageA(pWnd[count]->hwndSelf, WM_SHOWWINDOW, SW_HIDE, SW_PARENTCLOSING); SendMessageA(pWnd->hwndSelf, WM_SHOWWINDOW, SW_HIDE, SW_PARENTCLOSING);
pWnd[count]->flags |= WIN_NEEDS_SHOW_OWNEDPOPUP; pWnd->flags |= WIN_NEEDS_SHOW_OWNEDPOPUP;
} }
} }
} }
WIN_ReleaseWndPtr( pWnd );
} }
WIN_ReleaseWinArray( win_array );
WIN_ReleaseDesktop();
WIN_ReleaseWinArray(pWnd);
return TRUE; return TRUE;
} }
@ -2679,30 +2688,20 @@ HWND WINAPI GetLastActivePopup( HWND hwnd )
* The array must be freed with WIN_ReleaseWinArray. Return NULL * The array must be freed with WIN_ReleaseWinArray. Return NULL
* when no windows are found. * when no windows are found.
*/ */
WND **WIN_BuildWinArray( WND *wndPtr, UINT bwaFlags, UINT* pTotal ) HWND *WIN_BuildWinArray( HWND hwnd )
{ {
/* Future: this function will lock all windows associated with this array */ /* Future: this function will lock all windows associated with this array */
WND *pWnd, *wndPtr = WIN_FindWndPtr( hwnd );
WND **list, **ppWnd; HWND *list, *phwnd;
WND *pWnd; UINT count = 0;
UINT count = 0, skipOwned, skipHidden;
DWORD skipFlags;
skipHidden = bwaFlags & BWA_SKIPHIDDEN;
skipOwned = bwaFlags & BWA_SKIPOWNED;
skipFlags = (bwaFlags & BWA_SKIPDISABLED) ? WS_DISABLED : 0;
if( bwaFlags & BWA_SKIPICONIC ) skipFlags |= WS_MINIMIZE;
/* First count the windows */ /* First count the windows */
if (!wndPtr) if (!wndPtr) return NULL;
wndPtr = WIN_GetDesktop();
pWnd = WIN_LockWndPtr(wndPtr->child); pWnd = WIN_LockWndPtr(wndPtr->child);
while (pWnd) while (pWnd)
{ {
if( !(pWnd->dwStyle & skipFlags) && !(skipOwned && pWnd->owner) &&
(!skipHidden || (pWnd->dwStyle & WS_VISIBLE)) )
count++; count++;
WIN_UpdateWndPtr(&pWnd,pWnd->next); WIN_UpdateWndPtr(&pWnd,pWnd->next);
} }
@ -2711,34 +2710,29 @@ WND **WIN_BuildWinArray( WND *wndPtr, UINT bwaFlags, UINT* pTotal )
{ {
/* Now build the list of all windows */ /* Now build the list of all windows */
if ((list = (WND **)HeapAlloc( GetProcessHeap(), 0, sizeof(WND *) * (count + 1)))) if ((list = HeapAlloc( GetProcessHeap(), 0, sizeof(HWND) * (count + 1))))
{ {
for (pWnd = WIN_LockWndPtr(wndPtr->child), ppWnd = list, count = 0; pWnd; WIN_UpdateWndPtr(&pWnd,pWnd->next)) for (pWnd = WIN_LockWndPtr(wndPtr->child), phwnd = list, count = 0; pWnd; WIN_UpdateWndPtr(&pWnd,pWnd->next))
{ {
if( (pWnd->dwStyle & skipFlags) || (skipOwned && pWnd->owner) ); *phwnd++ = pWnd->hwndSelf;
else if( !skipHidden || pWnd->dwStyle & WS_VISIBLE )
{
*ppWnd++ = pWnd;
count++; count++;
} }
}
WIN_ReleaseWndPtr(pWnd); WIN_ReleaseWndPtr(pWnd);
*ppWnd = NULL; *phwnd = 0;
} }
else count = 0; else count = 0;
} else list = NULL; } else list = NULL;
if( pTotal ) *pTotal = count; WIN_ReleaseWndPtr( wndPtr );
return list; return list;
} }
/******************************************************************* /*******************************************************************
* WIN_ReleaseWinArray * WIN_ReleaseWinArray
*/ */
void WIN_ReleaseWinArray(WND **wndArray) void WIN_ReleaseWinArray(HWND *wndArray)
{ {
/* Future: this function will also unlock all windows associated with wndArray */ if (wndArray) HeapFree( GetProcessHeap(), 0, wndArray );
HeapFree( GetProcessHeap(), 0, wndArray );
} }
/******************************************************************* /*******************************************************************
@ -2746,82 +2740,28 @@ void WIN_ReleaseWinArray(WND **wndArray)
*/ */
BOOL WINAPI EnumWindows( WNDENUMPROC lpEnumFunc, LPARAM lParam ) BOOL WINAPI EnumWindows( WNDENUMPROC lpEnumFunc, LPARAM lParam )
{ {
WND **list, **ppWnd; HWND *list;
BOOL ret = TRUE;
int i, iWndsLocks;
/* We have to build a list of all windows first, to avoid */ /* We have to build a list of all windows first, to avoid */
/* unpleasant side-effects, for instance if the callback */ /* unpleasant side-effects, for instance if the callback */
/* function changes the Z-order of the windows. */ /* function changes the Z-order of the windows. */
if (!(list = WIN_BuildWinArray(WIN_GetDesktop(), 0, NULL ))) if (!(list = WIN_BuildWinArray( GetDesktopWindow() ))) return FALSE;
{
WIN_ReleaseDesktop();
return FALSE;
}
/* Now call the callback function for every window */ /* Now call the callback function for every window */
for (ppWnd = list; *ppWnd; ppWnd++)
{
LRESULT lpEnumFuncRetval;
int iWndsLocks = 0;
/* Make sure that the window still exists */
if (!IsWindow((*ppWnd)->hwndSelf)) continue;
/* To avoid any deadlocks, all the locks on the windows
structures must be suspended before the control
is passed to the application */
iWndsLocks = WIN_SuspendWndsLock(); iWndsLocks = WIN_SuspendWndsLock();
lpEnumFuncRetval = lpEnumFunc( (*ppWnd)->hwndSelf, lParam); for (i = 0; list[i]; i++)
WIN_RestoreWndsLock(iWndsLocks);
if (!lpEnumFuncRetval) break;
}
WIN_ReleaseWinArray(list);
WIN_ReleaseDesktop();
return TRUE;
}
/**********************************************************************
* WIN_EnumQueueWindows
*
* Helper for EnumTaskWindows16 and EnumThreadWindows.
*/
static BOOL WIN_EnumQueueWindows( HQUEUE16 queue, WNDENUMPROC func, LPARAM lParam )
{
WND **list, **ppWnd;
/* This function is the same as EnumWindows(), */
/* except for an added check on the window's task. */
if (!(list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL )))
{ {
WIN_ReleaseDesktop();
return FALSE;
}
/* Now call the callback function for every window */
for (ppWnd = list; *ppWnd; ppWnd++)
{
LRESULT funcRetval;
int iWndsLocks = 0;
/* Make sure that the window still exists */ /* Make sure that the window still exists */
if (!IsWindow((*ppWnd)->hwndSelf)) continue; if (!IsWindow( list[i] )) continue;
if ((*ppWnd)->hmemTaskQ != queue) continue; if (!(ret = lpEnumFunc( list[i], lParam ))) break;
/* To avoid any deadlocks, all the locks on the windows
structures must be suspended before the control
is passed to the application */
iWndsLocks = WIN_SuspendWndsLock();
funcRetval = func( (*ppWnd)->hwndSelf, lParam );
WIN_RestoreWndsLock(iWndsLocks);
if (!funcRetval) break;
} }
WIN_RestoreWndsLock(iWndsLocks);
WIN_ReleaseWinArray(list); WIN_ReleaseWinArray(list);
WIN_ReleaseDesktop(); return ret;
return TRUE;
} }
@ -2831,9 +2771,9 @@ static BOOL WIN_EnumQueueWindows( HQUEUE16 queue, WNDENUMPROC func, LPARAM lPara
BOOL16 WINAPI EnumTaskWindows16( HTASK16 hTask, WNDENUMPROC16 func, BOOL16 WINAPI EnumTaskWindows16( HTASK16 hTask, WNDENUMPROC16 func,
LPARAM lParam ) LPARAM lParam )
{ {
HQUEUE16 queue = GetTaskQueue16( hTask ); TDB *tdb = TASK_GetPtr( hTask );
if (!queue) return FALSE; if (!tdb) return FALSE;
return WIN_EnumQueueWindows( queue, (WNDENUMPROC)func, lParam ); return EnumThreadWindows( (DWORD)tdb->teb->tid, (WNDENUMPROC)func, lParam );
} }
@ -2842,9 +2782,22 @@ BOOL16 WINAPI EnumTaskWindows16( HTASK16 hTask, WNDENUMPROC16 func,
*/ */
BOOL WINAPI EnumThreadWindows( DWORD id, WNDENUMPROC func, LPARAM lParam ) BOOL WINAPI EnumThreadWindows( DWORD id, WNDENUMPROC func, LPARAM lParam )
{ {
HQUEUE16 queue = GetThreadQueue16( id ); HWND *list;
if (!queue) return FALSE; int i, iWndsLocks;
return WIN_EnumQueueWindows( queue, func, lParam );
if (!(list = WIN_BuildWinArray( GetDesktopWindow() ))) return FALSE;
/* Now call the callback function for every window */
iWndsLocks = WIN_SuspendWndsLock();
for (i = 0; list[i]; i++)
{
if (GetWindowThreadProcessId( list[i], NULL ) != id) continue;
if (!func( list[i], lParam )) break;
}
WIN_RestoreWndsLock(iWndsLocks);
WIN_ReleaseWinArray(list);
return TRUE;
} }
@ -2853,26 +2806,21 @@ BOOL WINAPI EnumThreadWindows( DWORD id, WNDENUMPROC func, LPARAM lParam )
* *
* Helper function for EnumChildWindows(). * Helper function for EnumChildWindows().
*/ */
static BOOL16 WIN_EnumChildWindows( WND **ppWnd, WNDENUMPROC func, LPARAM lParam ) static BOOL WIN_EnumChildWindows( HWND *list, WNDENUMPROC func, LPARAM lParam )
{ {
WND **childList; HWND *childList;
BOOL16 ret = FALSE; BOOL ret = FALSE;
for ( ; *ppWnd; ppWnd++) for ( ; *list; list++)
{ {
int iWndsLocks = 0;
/* Make sure that the window still exists */ /* Make sure that the window still exists */
if (!IsWindow((*ppWnd)->hwndSelf)) continue; if (!IsWindow( *list )) continue;
/* skip owned windows */
if (GetWindow( *list, GW_OWNER )) continue;
/* Build children list first */ /* Build children list first */
childList = WIN_BuildWinArray( *ppWnd, BWA_SKIPOWNED, NULL ); childList = WIN_BuildWinArray( *list );
/* To avoid any deadlocks, all the locks on the windows ret = func( *list, lParam );
structures must be suspended before the control
is passed to the application */
iWndsLocks = WIN_SuspendWndsLock();
ret = func( (*ppWnd)->hwndSelf, lParam );
WIN_RestoreWndsLock(iWndsLocks);
if (childList) if (childList)
{ {
@ -2888,20 +2836,16 @@ static BOOL16 WIN_EnumChildWindows( WND **ppWnd, WNDENUMPROC func, LPARAM lParam
/********************************************************************** /**********************************************************************
* EnumChildWindows (USER32.@) * EnumChildWindows (USER32.@)
*/ */
BOOL WINAPI EnumChildWindows( HWND parent, WNDENUMPROC func, BOOL WINAPI EnumChildWindows( HWND parent, WNDENUMPROC func, LPARAM lParam )
LPARAM lParam )
{ {
WND **list, *pParent; HWND *list;
int iWndsLocks;
if (!(pParent = WIN_FindWndPtr( parent ))) return FALSE; if (!(list = WIN_BuildWinArray( parent ))) return FALSE;
if (!(list = WIN_BuildWinArray( pParent, BWA_SKIPOWNED, NULL ))) iWndsLocks = WIN_SuspendWndsLock();
{
WIN_ReleaseWndPtr(pParent);
return FALSE;
}
WIN_EnumChildWindows( list, func, lParam ); WIN_EnumChildWindows( list, func, lParam );
WIN_RestoreWndsLock(iWndsLocks);
WIN_ReleaseWinArray(list); WIN_ReleaseWinArray(list);
WIN_ReleaseWndPtr(pParent);
return TRUE; return TRUE;
} }
@ -3051,22 +2995,20 @@ BOOL16 DRAG_QueryUpdate( HWND hQueryWnd, SEGPTR spDragInfo, BOOL bNoSend )
BOOL16 wParam, bResult = 0; BOOL16 wParam, bResult = 0;
POINT pt; POINT pt;
LPDRAGINFO16 ptrDragInfo = MapSL(spDragInfo); LPDRAGINFO16 ptrDragInfo = MapSL(spDragInfo);
WND *ptrQueryWnd = WIN_FindWndPtr(hQueryWnd),*ptrWnd;
RECT tempRect; RECT tempRect;
if( !ptrQueryWnd || !ptrDragInfo ) if (!ptrDragInfo) return FALSE;
goto end;
CONV_POINT16TO32( &ptrDragInfo->pt, &pt ); CONV_POINT16TO32( &ptrDragInfo->pt, &pt );
GetWindowRect(hQueryWnd,&tempRect); GetWindowRect(hQueryWnd,&tempRect);
if( !PtInRect(&tempRect,pt) || if( !PtInRect(&tempRect,pt) || !IsWindowEnabled(hQueryWnd)) return FALSE;
(ptrQueryWnd->dwStyle & WS_DISABLED) )
goto end;
if( !(ptrQueryWnd->dwStyle & WS_MINIMIZE) ) if (!IsIconic( hQueryWnd ))
{ {
WND *ptrWnd, *ptrQueryWnd = WIN_FindWndPtr(hQueryWnd);
tempRect = ptrQueryWnd->rectClient; tempRect = ptrQueryWnd->rectClient;
if(ptrQueryWnd->parent) if(ptrQueryWnd->parent)
MapWindowPoints( ptrQueryWnd->parent->hwndSelf, 0, MapWindowPoints( ptrQueryWnd->parent->hwndSelf, 0,
@ -3097,9 +3039,13 @@ BOOL16 DRAG_QueryUpdate( HWND hQueryWnd, SEGPTR spDragInfo, BOOL bNoSend )
} }
if(bResult) if(bResult)
goto end; {
WIN_ReleaseWndPtr(ptrQueryWnd);
return bResult;
}
} }
else wParam = 1; else wParam = 1;
WIN_ReleaseWndPtr(ptrQueryWnd);
} }
else wParam = 1; else wParam = 1;
@ -3107,15 +3053,11 @@ BOOL16 DRAG_QueryUpdate( HWND hQueryWnd, SEGPTR spDragInfo, BOOL bNoSend )
ptrDragInfo->hScope = hQueryWnd; ptrDragInfo->hScope = hQueryWnd;
bResult = ( bNoSend ) if (bNoSend) bResult = (GetWindowLongA( hQueryWnd, GWL_EXSTYLE ) & WS_EX_ACCEPTFILES) != 0;
? ptrQueryWnd->dwExStyle & WS_EX_ACCEPTFILES else bResult = SendMessage16( hQueryWnd, WM_QUERYDROPOBJECT, (WPARAM16)wParam, spDragInfo );
: SendMessage16( hQueryWnd ,WM_QUERYDROPOBJECT ,
(WPARAM16)wParam ,(LPARAM) spDragInfo ); if( !bResult ) CONV_POINT32TO16( &pt, &ptrDragInfo->pt );
if( !bResult )
CONV_POINT32TO16( &pt, &ptrDragInfo->pt );
end:
WIN_ReleaseWndPtr(ptrQueryWnd);
return bResult; return bResult;
} }
@ -3183,25 +3125,17 @@ DWORD WINAPI DragObject16( HWND16 hwndScope, HWND16 hWnd, UINT16 wObj,
SEGPTR spDragInfo; SEGPTR spDragInfo;
HCURSOR16 hDragCursor=0, hOldCursor=0, hBummer=0; HCURSOR16 hDragCursor=0, hOldCursor=0, hBummer=0;
HGLOBAL16 hDragInfo = GlobalAlloc16( GMEM_SHARE | GMEM_ZEROINIT, 2*sizeof(DRAGINFO16)); HGLOBAL16 hDragInfo = GlobalAlloc16( GMEM_SHARE | GMEM_ZEROINIT, 2*sizeof(DRAGINFO16));
WND *wndPtr = WIN_FindWndPtr(hWnd);
HCURSOR16 hCurrentCursor = 0; HCURSOR16 hCurrentCursor = 0;
HWND16 hCurrentWnd = 0; HWND16 hCurrentWnd = 0;
lpDragInfo = (LPDRAGINFO16) GlobalLock16(hDragInfo); lpDragInfo = (LPDRAGINFO16) GlobalLock16(hDragInfo);
spDragInfo = K32WOWGlobalLock16(hDragInfo); spDragInfo = K32WOWGlobalLock16(hDragInfo);
if( !lpDragInfo || !spDragInfo ) if( !lpDragInfo || !spDragInfo ) return 0L;
{
WIN_ReleaseWndPtr(wndPtr);
return 0L;
}
hBummer = LoadCursorA(0, MAKEINTRESOURCEA(OCR_NO)); if (!(hBummer = LoadCursorA(0, MAKEINTRESOURCEA(OCR_NO))))
if( !hBummer || !wndPtr )
{ {
GlobalFree16(hDragInfo); GlobalFree16(hDragInfo);
WIN_ReleaseWndPtr(wndPtr);
return 0L; return 0L;
} }
@ -3210,7 +3144,6 @@ DWORD WINAPI DragObject16( HWND16 hwndScope, HWND16 hWnd, UINT16 wObj,
if( !(hDragCursor = CURSORICON_IconToCursor(hCursor, FALSE)) ) if( !(hDragCursor = CURSORICON_IconToCursor(hCursor, FALSE)) )
{ {
GlobalFree16(hDragInfo); GlobalFree16(hDragInfo);
WIN_ReleaseWndPtr(wndPtr);
return 0L; return 0L;
} }
@ -3232,8 +3165,7 @@ DWORD WINAPI DragObject16( HWND16 hwndScope, HWND16 hWnd, UINT16 wObj,
do do
{ {
do{ WaitMessage(); } GetMessageW( &msg, 0, WM_MOUSEFIRST, WM_MOUSELAST );
while( !PeekMessageA(&msg,0,WM_MOUSEFIRST,WM_MOUSELAST,PM_REMOVE) );
*(lpDragInfo+1) = *lpDragInfo; *(lpDragInfo+1) = *lpDragInfo;
@ -3288,7 +3220,6 @@ DWORD WINAPI DragObject16( HWND16 hwndScope, HWND16 hWnd, UINT16 wObj,
else else
msg.lParam = 0; msg.lParam = 0;
GlobalFree16(hDragInfo); GlobalFree16(hDragInfo);
WIN_ReleaseWndPtr(wndPtr);
return (DWORD)(msg.lParam); return (DWORD)(msg.lParam);
} }

View File

@ -1570,37 +1570,33 @@ BOOL WINPOS_SetActiveWindow( HWND hWnd, BOOL fMouse, BOOL fChangeFocus)
/* send WM_ACTIVATEAPP if necessary */ /* send WM_ACTIVATEAPP if necessary */
if (hOldActiveQueue != hNewActiveQueue) if (hOldActiveQueue != hNewActiveQueue)
{ {
WND **list, **ppWnd; HWND *list, *phwnd;
WND *pDesktop = WIN_GetDesktop(); DWORD old_thread = GetWindowThreadProcessId( hwndPrevActive, NULL );
if ((list = WIN_BuildWinArray( pDesktop, 0, NULL )))
{
DWORD new_thread = GetWindowThreadProcessId( hwndActive, NULL ); DWORD new_thread = GetWindowThreadProcessId( hwndActive, NULL );
for (ppWnd = list; *ppWnd; ppWnd++)
{
if (!IsWindow( (*ppWnd)->hwndSelf )) continue;
if ((*ppWnd)->hmemTaskQ == hOldActiveQueue) if ((list = WIN_BuildWinArray( GetDesktopWindow() )))
SendMessageW( (*ppWnd)->hwndSelf, WM_ACTIVATEAPP, 0, new_thread ); {
for (phwnd = list; *phwnd; phwnd++)
{
if (!IsWindow( *phwnd )) continue;
if (GetWindowThreadProcessId( *phwnd, NULL ) == old_thread)
SendMessageW( *phwnd, WM_ACTIVATEAPP, 0, new_thread );
} }
WIN_ReleaseWinArray(list); WIN_ReleaseWinArray(list);
} }
hActiveQueue = hNewActiveQueue; hActiveQueue = hNewActiveQueue;
if ((list = WIN_BuildWinArray(pDesktop, 0, NULL ))) if ((list = WIN_BuildWinArray( GetDesktopWindow() )))
{ {
DWORD old_thread = GetWindowThreadProcessId( hwndPrevActive, NULL ); for (phwnd = list; *phwnd; phwnd++)
for (ppWnd = list; *ppWnd; ppWnd++)
{ {
if (!IsWindow( (*ppWnd)->hwndSelf )) continue; if (!IsWindow( *phwnd )) continue;
if (GetWindowThreadProcessId( *phwnd, NULL ) == new_thread)
if ((*ppWnd)->hmemTaskQ == hNewActiveQueue) SendMessageW( *phwnd, WM_ACTIVATEAPP, 1, old_thread );
SendMessageW( (*ppWnd)->hwndSelf, WM_ACTIVATEAPP, 1, old_thread );
} }
WIN_ReleaseWinArray(list); WIN_ReleaseWinArray(list);
} }
WIN_ReleaseDesktop();
if (hWnd && !IsWindow(hWnd)) goto CLEANUP; if (hWnd && !IsWindow(hWnd)) goto CLEANUP;
} }

View File

@ -1109,11 +1109,12 @@ BOOL X11DRV_GetClipboardData(UINT wFormat)
* Any top level window can own the selection. See X11DRV_CLIPBOARD_Acquire * Any top level window can own the selection. See X11DRV_CLIPBOARD_Acquire
* for a more detailed description of this. * for a more detailed description of this.
*/ */
void X11DRV_ResetSelectionOwner(WND *pWnd, BOOL bFooBar) void X11DRV_ResetSelectionOwner(HWND hwnd, BOOL bFooBar)
{ {
Display *display = thread_display(); Display *display = thread_display();
HWND hWndClipOwner = 0; HWND hWndClipOwner = 0;
Window XWnd = get_whole_window(pWnd); HWND tmp;
Window XWnd = X11DRV_get_whole_window(hwnd);
Atom xaClipboard; Atom xaClipboard;
BOOL bLostSelection = FALSE; BOOL bLostSelection = FALSE;
@ -1141,11 +1142,8 @@ void X11DRV_ResetSelectionOwner(WND *pWnd, BOOL bFooBar)
selectionPrevWindow = selectionWindow; selectionPrevWindow = selectionWindow;
selectionWindow = None; selectionWindow = None;
if( pWnd->next ) if (!(tmp = GetWindow( hwnd, GW_HWNDNEXT ))) tmp = GetWindow( hwnd, GW_HWNDFIRST );
selectionWindow = get_whole_window(pWnd->next); if (tmp && tmp != hwnd) selectionWindow = X11DRV_get_whole_window(tmp);
else if( pWnd->parent )
if( pWnd->parent->child != pWnd )
selectionWindow = get_whole_window(pWnd->parent->child);
if( selectionWindow != None ) if( selectionWindow != None )
{ {