Removed a number of direct accesses to the window structure.

This commit is contained in:
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 RegisterClipboardFormat(str) TTYDRV_RegisterClipboardFormat
@ cdecl IsSelectionOwner() TTYDRV_IsSelectionOwner
@ cdecl ResetSelectionOwner(ptr long) TTYDRV_ResetSelectionOwner

View File

@ -212,10 +212,3 @@ BOOL TTYDRV_IsSelectionOwner(void)
{
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())
{
/* call 16-bit window proc directly */
WND *wndPtr;
WNDPROC16 winproc;
/* 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 )))
{
WARN("invalid hwnd %04x\n", hwnd );
return 0;
}
winproc = (WNDPROC16)wndPtr->winproc;
WIN_ReleaseWndPtr( wndPtr );
if (!(winproc = (WNDPROC16)GetWindowLong16( hwnd, GWL_WNDPROC ))) return 0;
SPY_EnterMessage( SPY_SENDMESSAGE16, 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.
* 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;
POINT pt;
MSG msg;
RECT rectWindow;
GetWindowRect(wndPtr->hwndSelf,&rectWindow);
GetWindowRect( hwnd, &rectWindow );
if ((wParam & 0xfff0) == SC_MOVE)
{
/* Move pointer at the center of the caption */
RECT rect;
NC_GetInsideRect( wndPtr->hwndSelf, &rect );
if (wndPtr->dwStyle & WS_SYSMENU)
NC_GetInsideRect( hwnd, &rect );
if (style & WS_SYSMENU)
rect.left += GetSystemMetrics(SM_CXSIZE) + 1;
if (wndPtr->dwStyle & WS_MINIMIZEBOX)
if (style & WS_MINIMIZEBOX)
rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
if (wndPtr->dwStyle & WS_MAXIMIZEBOX)
if (style & WS_MAXIMIZEBOX)
rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
pt.x = rectWindow.left + (rect.right - rect.left) / 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)
{
case WM_MOUSEMOVE:
hittest = NC_HandleNCHitTest( wndPtr->hwndSelf, msg.pt );
hittest = NC_HandleNCHitTest( hwnd, msg.pt );
if ((hittest < HTLEFT) || (hittest > HTBOTTOMRIGHT))
hittest = 0;
break;
@ -1641,8 +1641,7 @@ static LONG start_size_move( WND* wndPtr, WPARAM wParam, POINT *capturePoint )
*capturePoint = pt;
}
SetCursorPos( pt.x, pt.y );
NC_HandleSetCursor( wndPtr->hwndSelf,
wndPtr->hwndSelf, MAKELONG( hittest, WM_MOUSEMOVE ));
NC_HandleSetCursor( hwnd, hwnd, MAKELONG( hittest, WM_MOUSEMOVE ));
return hittest;
}
@ -1657,13 +1656,15 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
MSG msg;
RECT sizingRect, mouseRect, origRect;
HDC hdc;
HWND parent;
LONG hittest = (LONG)(wParam & 0x0f);
HCURSOR16 hDragCursor = 0, hOldCursor = 0;
POINT minTrack, maxTrack;
POINT capturePoint, pt;
WND * wndPtr = WIN_FindWndPtr( hwnd );
BOOL thickframe = HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle );
BOOL iconic = wndPtr->dwStyle & WS_MINIMIZE;
LONG style = GetWindowLongA( hwnd, GWL_STYLE );
LONG exstyle = GetWindowLongA( hwnd, GWL_EXSTYLE );
BOOL thickframe = HAS_THICKFRAME( style, exstyle );
BOOL iconic = style & WS_MINIMIZE;
BOOL moved = FALSE;
DWORD dwPoint = GetMessagePos ();
BOOL DragFullWindows = FALSE;
@ -1678,26 +1679,25 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
pt.y = SHIWORD(dwPoint);
capturePoint = pt;
if (IsZoomed(hwnd) || !IsWindowVisible(hwnd) ||
(wndPtr->dwExStyle & WS_EX_MANAGED)) goto END;
if (IsZoomed(hwnd) || !IsWindowVisible(hwnd) || (exstyle & WS_EX_MANAGED)) return;
if ((wParam & 0xfff0) == SC_MOVE)
{
if (!hittest) hittest = start_size_move( wndPtr, wParam, &capturePoint );
if (!hittest) goto END;
if (!hittest) hittest = start_size_move( hwnd, wParam, &capturePoint, style );
if (!hittest) return;
}
else /* SC_SIZE */
{
if (!thickframe) goto END;
if (!thickframe) return;
if ( hittest && hittest != HTSYSMENU ) hittest += 2;
else
{
SetCapture(hwnd);
hittest = start_size_move( wndPtr, wParam, &capturePoint );
hittest = start_size_move( hwnd, wParam, &capturePoint, style );
if (!hittest)
{
ReleaseCapture();
goto END;
return;
}
}
}
@ -1705,12 +1705,21 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
/* Get min/max info */
WINPOS_GetMinMaxInfo( hwnd, NULL, NULL, &minTrack, &maxTrack );
sizingRect = wndPtr->rectWindow;
origRect = sizingRect;
if (wndPtr->dwStyle & WS_CHILD)
GetClientRect( wndPtr->parent->hwndSelf, &mouseRect );
GetWindowRect( hwnd, &sizingRect );
if (style & WS_CHILD)
{
parent = GetParent(hwnd);
/* make sizing rect relative to parent */
MapWindowPoints( 0, parent, (POINT*)&sizingRect, 2 );
GetClientRect( parent, &mouseRect );
}
else
{
parent = 0;
SetRect(&mouseRect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
}
origRect = sizingRect;
if (ON_LEFT_BORDER(hittest))
{
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.bottom = min( mouseRect.bottom, sizingRect.top+maxTrack.y );
}
if (wndPtr->dwStyle & WS_CHILD)
{
MapWindowPoints( wndPtr->parent->hwndSelf, 0, (LPPOINT)&mouseRect, 2 );
}
if (parent) MapWindowPoints( parent, 0, (LPPOINT)&mouseRect, 2 );
/* 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 */
{
@ -1754,8 +1760,7 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
SetCapture( hwnd );
/* grab the server only when moving top-level windows without desktop */
grab = (!DragFullWindows && (root_window == DefaultRootWindow(gdi_display)) &&
(wndPtr->parent->hwndSelf == GetDesktopWindow()));
grab = (!DragFullWindows && !parent && (root_window == DefaultRootWindow(gdi_display)));
wine_tsx11_lock();
if (grab)
@ -1767,9 +1772,10 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
old_gdi_display = gdi_display;
gdi_display = display;
}
XGrabPointer( display, get_whole_window(wndPtr), False,
XGrabPointer( display, X11DRV_get_whole_window(hwnd), False,
PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
GrabModeAsync, GrabModeAsync, get_client_window(wndPtr->parent),
GrabModeAsync, GrabModeAsync,
parent ? X11DRV_get_client_window(parent) : root_window,
None, CurrentTime );
wine_tsx11_unlock();
@ -1874,7 +1880,7 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
else if (moved && !DragFullWindows)
draw_moving_frame( hdc, &sizingRect, thickframe );
ReleaseDC( wndPtr->parent->hwndSelf, hdc );
ReleaseDC( parent, hdc );
wine_tsx11_lock();
XUngrabPointer( display, CurrentTime );
@ -1887,8 +1893,7 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
}
wine_tsx11_unlock();
if (HOOK_CallHooksA( WH_CBT, HCBT_MOVESIZE, hwnd, (LPARAM)&sizingRect ))
sizingRect = wndPtr->rectWindow;
if (HOOK_CallHooksA( WH_CBT, HCBT_MOVESIZE, hwnd, (LPARAM)&sizingRect )) moved = FALSE;
SendMessageA( hwnd, WM_EXITSIZEMOVE, 0, 0 );
SendMessageA( hwnd, WM_SETVISIBLE, !IsIconic(hwnd), 0L);
@ -1930,15 +1935,12 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
if( !moved )
{
if( wndPtr->dwStyle & WS_SYSMENU )
if(style & WS_SYSMENU )
SendMessageA( hwnd, WM_SYSCOMMAND,
SC_MOUSEMENU + HTSYSMENU, MAKELONG(pt.x,pt.y));
}
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 (*pRegisterClipboardFormat)(LPCSTR); /* Register a clipboard format */
BOOL (*pIsSelectionOwner)(void); /* Check if we own the selection */
void (*pResetSelectionOwner)(struct tagWND *, BOOL);
void (*pResetSelectionOwner)(HWND, BOOL);
/* windowing functions */
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_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 */
extern int WIN_SuspendWndsLock( void );
extern void WIN_RestoreWndsLock(int ipreviousLock);
@ -102,16 +96,14 @@ extern BOOL WIN_CreateDesktopWindow(void);
extern HWND WIN_GetTopParent( HWND hwnd );
extern WND* WIN_GetTopParentPtr( WND* pWnd );
extern BOOL WIN_IsWindowDrawable(WND*, BOOL );
extern WND** WIN_BuildWinArray( WND *wndPtr, UINT bwa, UINT* pnum );
extern void WIN_ReleaseWinArray(WND **wndArray);
extern HWND *WIN_BuildWinArray( HWND hwnd );
extern void WIN_ReleaseWinArray( HWND *wndArray );
extern BOOL WIN_InternalShowOwnedPopups( HWND owner, BOOL fShow, BOOL unmanagedOnly );
extern HWND CARET_GetHwnd(void);
extern void CARET_GetRect(LPRECT lprc); /* windows/caret.c */
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 void PROPERTY_RemoveWindowProps( WND *pWnd ); /* windows/property.c */

View File

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

View File

@ -35,21 +35,24 @@ static short iMenuSysKey = 0;
*
* 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))
SendMessageW( wndPtr->hwndSelf, WM_MOVE, 0,
MAKELONG(wndPtr->rectClient.left, wndPtr->rectClient.top));
SendMessageW( hwnd, WM_MOVE, 0, MAKELONG(rect.left, rect.top));
if (!(flags & SWP_NOCLIENTSIZE))
{
if (wndPtr->dwStyle & WS_MAXIMIZE) wp = SIZE_MAXIMIZED;
else if (wndPtr->dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED;
WPARAM wp = SIZE_RESTORED;
if (IsZoomed(hwnd)) wp = SIZE_MAXIMIZED;
else if (IsIconic(hwnd)) wp = SIZE_MINIMIZED;
SendMessageW( wndPtr->hwndSelf, WM_SIZE, wp,
MAKELONG(wndPtr->rectClient.right-wndPtr->rectClient.left,
wndPtr->rectClient.bottom-wndPtr->rectClient.top));
SendMessageW( hwnd, WM_SIZE, wp, MAKELONG(rect.right-rect.left, rect.bottom-rect.top) );
}
}
@ -59,21 +62,24 @@ static void DEFWND_HandleWindowPosChanged( WND *wndPtr, UINT flags )
*
* Set the window text.
*/
void DEFWND_SetTextA( WND *wndPtr, LPCSTR text )
static void DEFWND_SetTextA( HWND hwnd, LPCSTR text )
{
int count;
WCHAR *textW;
WND *wndPtr;
if (!text) text = "";
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 = 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 );
else
ERR("Not enough memory for window text\n");
WIN_ReleaseWndPtr( wndPtr );
if (USER_Driver.pSetWindowText)
USER_Driver.pSetWindowText(wndPtr->hwndSelf, wndPtr->text);
if (USER_Driver.pSetWindowText) USER_Driver.pSetWindowText( hwnd, textW );
}
/***********************************************************************
@ -81,22 +87,25 @@ void DEFWND_SetTextA( WND *wndPtr, LPCSTR 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};
WND *wndPtr;
int count;
if (!text) text = empty_string;
count = strlenW(text) + 1;
if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return;
if (wndPtr->text) HeapFree(GetProcessHeap(), 0, wndPtr->text);
if ((wndPtr->text = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WCHAR))))
strcpyW( wndPtr->text, text );
else
ERR("Not enough memory for window text\n");
text = wndPtr->text;
WIN_ReleaseWndPtr( wndPtr );
if (USER_Driver.pSetWindowText)
USER_Driver.pSetWindowText(wndPtr->hwndSelf, wndPtr->text);
if (USER_Driver.pSetWindowText) USER_Driver.pSetWindowText( hwnd, text );
}
/***********************************************************************
@ -148,8 +157,9 @@ HBRUSH DEFWND_ControlColor( HDC hDC, UINT ctlType )
/***********************************************************************
* 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;
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 );
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.
*/
static void DEFWND_Print(
WND* wndPtr,
HDC hdc,
ULONG uFlags)
static void DEFWND_Print( HWND hwnd, HDC hdc, ULONG uFlags)
{
/*
* Visibility flag.
*/
if ( (uFlags & PRF_CHECKVISIBLE) &&
!IsWindowVisible(wndPtr->hwndSelf) )
!IsWindowVisible(hwnd) )
return;
/*
@ -204,13 +212,13 @@ static void DEFWND_Print(
* Background
*/
if ( uFlags & PRF_ERASEBKGND)
SendMessageW(wndPtr->hwndSelf, WM_ERASEBKGND, (WPARAM)hdc, 0);
SendMessageW(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0);
/*
* Client area
*/
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.
*/
static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
LPARAM lParam, BOOL unicode )
static LRESULT DEFWND_DefWinProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
LRESULT (WINAPI *pSendMessage)(HWND, UINT, WPARAM, LPARAM);
BOOL (WINAPI *pPostMessage)(HWND, UINT, WPARAM, LPARAM);
pSendMessage = unicode ? SendMessageW : SendMessageA;
pPostMessage = unicode ? PostMessageW : PostMessageA;
switch(msg)
{
case WM_NCPAINT:
return NC_HandleNCPaint( wndPtr->hwndSelf, (HRGN)wParam );
return NC_HandleNCPaint( hwnd, (HRGN)wParam );
case WM_NCHITTEST:
{
POINT pt;
pt.x = SLOWORD(lParam);
pt.y = SHIWORD(lParam);
return NC_HandleNCHitTest( wndPtr->hwndSelf, pt );
return NC_HandleNCHitTest( hwnd, pt );
}
case WM_NCLBUTTONDOWN:
return NC_HandleNCLButtonDown( wndPtr->hwndSelf, wParam, lParam );
return NC_HandleNCLButtonDown( hwnd, wParam, lParam );
case WM_LBUTTONDBLCLK:
case WM_NCLBUTTONDBLCLK:
return NC_HandleNCLButtonDblClk( wndPtr->hwndSelf, wParam, lParam );
return NC_HandleNCLButtonDblClk( hwnd, wParam, lParam );
case WM_NCRBUTTONDOWN:
/* in Windows, capture is taken when right-clicking on the caption bar */
if (wParam==HTCAPTION)
{
SetCapture(wndPtr->hwndSelf);
SetCapture(hwnd);
}
break;
@ -325,15 +326,14 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
{
POINT pt;
if (wndPtr->hwndSelf == GetCapture())
if (hwnd == GetCapture())
/* release capture if we took it on WM_NCRBUTTONDOWN */
ReleaseCapture();
pt.x = SLOWORD(lParam);
pt.y = SHIWORD(lParam);
ClientToScreen(wndPtr->hwndSelf, &pt);
pSendMessage( wndPtr->hwndSelf, WM_CONTEXTMENU,
wndPtr->hwndSelf, MAKELPARAM(pt.x, pt.y) );
ClientToScreen(hwnd, &pt);
SendMessageW( hwnd, WM_CONTEXTMENU, hwnd, MAKELPARAM(pt.x, pt.y) );
}
break;
@ -347,89 +347,89 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
break;
case WM_CONTEXTMENU:
if( wndPtr->dwStyle & WS_CHILD )
pSendMessage( wndPtr->parent->hwndSelf, msg, wParam, lParam );
else if (wndPtr->hSysMenu)
if (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD)
SendMessageW( GetParent(hwnd), msg, wParam, lParam );
else
{
LONG hitcode;
POINT pt;
WND *wndPtr = WIN_FindWndPtr( hwnd );
HMENU hMenu = wndPtr->hSysMenu;
WIN_ReleaseWndPtr( wndPtr );
if (!hMenu) return 0;
pt.x = SLOWORD(lParam);
pt.y = SHIWORD(lParam);
/*
* 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);
hitcode = NC_HandleNCHitTest(hwnd, pt);
/* Track system popup if click was in the caption area. */
if (hitcode==HTCAPTION || hitcode==HTSYSMENU)
TrackPopupMenu(GetSystemMenu(wndPtr->hwndSelf, FALSE),
TrackPopupMenu(GetSystemMenu(hwnd, FALSE),
TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
pt.x, pt.y, 0, wndPtr->hwndSelf, NULL);
pt.x, pt.y, 0, hwnd, NULL);
}
break;
case WM_NCACTIVATE:
return NC_HandleNCActivate( wndPtr->hwndSelf, wParam );
return NC_HandleNCActivate( hwnd, wParam );
case WM_NCDESTROY:
if (wndPtr->text) HeapFree( GetProcessHeap(), 0, wndPtr->text );
wndPtr->text = NULL;
if (wndPtr->pVScroll) HeapFree( GetProcessHeap(), 0, wndPtr->pVScroll );
if (wndPtr->pHScroll) HeapFree( GetProcessHeap(), 0, wndPtr->pHScroll );
wndPtr->pVScroll = wndPtr->pHScroll = NULL;
return 0;
{
WND *wndPtr = WIN_FindWndPtr( hwnd );
if (!wndPtr) return 0;
if (wndPtr->text) HeapFree( GetProcessHeap(), 0, wndPtr->text );
wndPtr->text = NULL;
if (wndPtr->pVScroll) HeapFree( GetProcessHeap(), 0, wndPtr->pVScroll );
if (wndPtr->pHScroll) HeapFree( GetProcessHeap(), 0, wndPtr->pHScroll );
wndPtr->pVScroll = wndPtr->pHScroll = NULL;
WIN_ReleaseWndPtr( wndPtr );
return 0;
}
case WM_PRINT:
DEFWND_Print(wndPtr, (HDC)wParam, lParam);
DEFWND_Print(hwnd, (HDC)wParam, lParam);
return 0;
case WM_PAINTICON:
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint( wndPtr->hwndSelf, &ps );
HDC hdc = BeginPaint( hwnd, &ps );
if( hdc )
{
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 -
GetSystemMetrics(SM_CXICON))/2;
int y = (wndPtr->rectWindow.bottom - wndPtr->rectWindow.top -
GetSystemMetrics(SM_CYICON))/2;
TRACE("Painting class icon: vis rect=(%i,%i - %i,%i)\n",
ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom );
DrawIcon( hdc, x, y, hIcon );
RECT rc;
int x, y;
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",
ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom );
DrawIcon( hdc, x, y, hIcon );
}
EndPaint( wndPtr->hwndSelf, &ps );
EndPaint( hwnd, &ps );
}
return 0;
}
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;
case WM_SETREDRAW:
DEFWND_SetRedraw( wndPtr, wParam );
DEFWND_SetRedraw( hwnd, wParam );
return 0;
case WM_CLOSE:
DestroyWindow( wndPtr->hwndSelf );
DestroyWindow( hwnd );
return 0;
case WM_MOUSEACTIVATE:
if (wndPtr->dwStyle & WS_CHILD)
if (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD)
{
LONG ret = pSendMessage( wndPtr->parent->hwndSelf,
WM_MOUSEACTIVATE, wParam, lParam );
LONG ret = SendMessageW( GetParent(hwnd), WM_MOUSEACTIVATE, wParam, lParam );
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 window, if it's being activated and not minimized */
if (LOWORD(wParam) != WA_INACTIVE) {
if (!(wndPtr->dwStyle & WS_MINIMIZE))
SetFocus(wndPtr->hwndSelf);
if (!IsIconic(hwnd)) SetFocus(hwnd);
}
break;
case WM_MOUSEWHEEL:
if (wndPtr->dwStyle & WS_CHILD)
{
return pSendMessage( wndPtr->parent->hwndSelf,
WM_MOUSEWHEEL, wParam, lParam );
}
case WM_MOUSEWHEEL:
if (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD)
return SendMessageW( GetParent(hwnd), WM_MOUSEWHEEL, wParam, lParam );
break;
case WM_ERASEBKGND:
@ -458,13 +454,13 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
{
RECT rect;
HDC hdc = (HDC)wParam;
HBRUSH hbr = GetClassLongW( wndPtr->hwndSelf, GCL_HBRBACKGROUND );
HBRUSH hbr = GetClassLongW( hwnd, GCL_HBRBACKGROUND );
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 */
GetClientRect( wndPtr->hwndSelf, &rect );
GetClientRect( hwnd, &rect );
DPtoLP( hdc, (LPPOINT)&rect, 2 );
}
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) );
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,
* give the parent first chance to set the cursor */
if ((LOWORD(lParam) < HTSIZEFIRST) || (LOWORD(lParam) > HTSIZELAST))
{
if (pSendMessage(wndPtr->parent->hwndSelf, WM_SETCURSOR, wParam, lParam))
return TRUE;
if (SendMessageW(GetParent(hwnd), WM_SETCURSOR, wParam, lParam)) return TRUE;
}
}
return NC_HandleSetCursor( wndPtr->hwndSelf, wParam, lParam );
return NC_HandleSetCursor( hwnd, wParam, lParam );
case WM_SYSCOMMAND:
{
POINT pt;
pt.x = SLOWORD(lParam);
pt.y = SHIWORD(lParam);
return NC_HandleSysCommand( wndPtr->hwndSelf, wParam, pt );
return NC_HandleSysCommand( hwnd, wParam, pt );
}
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 */
{
HWND hWnd = WIN_GetTopParent( wndPtr->hwndSelf );
wndPtr = WIN_FindWndPtr( hWnd );
if( wndPtr && !(wndPtr->clsStyle & CS_NOCLOSE) )
pPostMessage( hWnd, WM_SYSCOMMAND, SC_CLOSE, 0 );
WIN_ReleaseWndPtr(wndPtr);
HWND top = WIN_GetTopParent( hwnd );
if (!(GetClassLongW( top, GCL_STYLE ) & CS_NOCLOSE))
PostMessageW( top, WM_SYSCOMMAND, SC_CLOSE, 0 );
}
}
else if( wParam == VK_F10 )
iF10Key = 1;
else
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;
case WM_KEYUP:
@ -544,42 +537,44 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
/* Press and release F10 or ALT */
if (((wParam == VK_MENU) && iMenuSysKey) ||
((wParam == VK_F10) && iF10Key))
pSendMessage( WIN_GetTopParent(wndPtr->hwndSelf),
WM_SYSCOMMAND, SC_KEYMENU, 0L );
SendMessageW( WIN_GetTopParent(hwnd), WM_SYSCOMMAND, SC_KEYMENU, 0L );
iMenuSysKey = iF10Key = 0;
break;
case WM_SYSCHAR:
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;
}
if ((HIWORD(lParam) & KEYDATA_ALT) && wParam)
{
if (wParam == VK_TAB || wParam == VK_ESCAPE) break;
if (wParam == VK_SPACE && (wndPtr->dwStyle & WS_CHILD))
pSendMessage( wndPtr->parent->hwndSelf, msg, wParam, lParam );
if (wParam == VK_SPACE && (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD))
SendMessageW( GetParent(hwnd), msg, wParam, lParam );
else
pSendMessage( wndPtr->hwndSelf, WM_SYSCOMMAND, SC_KEYMENU, wParam );
SendMessageW( hwnd, WM_SYSCOMMAND, SC_KEYMENU, wParam );
}
else /* check for Ctrl-Esc */
if (wParam != VK_ESCAPE) MessageBeep(0);
break;
case WM_SHOWWINDOW:
if (!lParam) return 0; /* sent from ShowWindow */
if (!(wndPtr->dwStyle & WS_POPUP) || !wndPtr->owner) return 0;
if ((wndPtr->dwStyle & WS_VISIBLE) && wParam) return 0;
else if (!(wndPtr->dwStyle & WS_VISIBLE) && !wParam) return 0;
ShowWindow( wndPtr->hwndSelf, wParam ? SW_SHOWNOACTIVATE : SW_HIDE );
break;
{
LONG style = GetWindowLongW( hwnd, GWL_STYLE );
if (!lParam) return 0; /* sent from ShowWindow */
if (!(style & WS_POPUP)) return 0;
if ((style & WS_VISIBLE) && wParam) return 0;
if (!(style & WS_VISIBLE) && !wParam) return 0;
if (!GetWindow( hwnd, GW_OWNER )) return 0;
ShowWindow( hwnd, wParam ? SW_SHOWNOACTIVATE : SW_HIDE );
break;
}
case WM_CANCELMODE:
if (wndPtr->parent == WIN_GetDesktop()) EndMenu();
if (GetCapture() == wndPtr->hwndSelf) ReleaseCapture();
WIN_ReleaseDesktop();
if (!(GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD)) EndMenu();
if (GetCapture() == hwnd) ReleaseCapture();
break;
case WM_VKEYTOITEM:
@ -590,27 +585,32 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
return DRAG_FILE;
case WM_QUERYDROPOBJECT:
if (wndPtr->dwExStyle & WS_EX_ACCEPTFILES) return 1;
break;
return (GetWindowLongA( hwnd, GWL_EXSTYLE ) & WS_EX_ACCEPTFILES) != 0;
case WM_QUERYDRAGICON:
{
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;
for(len=1; len<64; len++)
if((hIcon = LoadIconW(wndPtr->hInstance, MAKEINTRESOURCEW(len))))
if((hIcon = LoadIconW(instance, MAKEINTRESOURCEW(len))))
return (LRESULT)hIcon;
return (LRESULT)LoadIconW(0, IDI_APPLICATIONW);
}
break;
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:
if (IsWindowUnicode(wndPtr->hwndSelf)) return NFR_UNICODE;
if (IsWindowUnicode(hwnd)) return NFR_UNICODE;
else return NFR_ANSI;
case WM_QUERYOPEN:
@ -619,14 +619,14 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
case WM_SETICON:
if (USER_Driver.pSetWindowIcon)
return USER_Driver.pSetWindowIcon( wndPtr->hwndSelf, lParam, (wParam != ICON_SMALL) );
return USER_Driver.pSetWindowIcon( hwnd, lParam, (wParam != ICON_SMALL) );
else
{
int index = (wParam != ICON_SMALL) ? GCL_HICON : GCL_HICONSM;
HICON hOldIcon = GetClassLongW(wndPtr->hwndSelf, index);
SetClassLongW(wndPtr->hwndSelf, index, lParam);
HICON hOldIcon = GetClassLongW(hwnd, index);
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_NOZORDER);
return hOldIcon;
@ -635,11 +635,11 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
case WM_GETICON:
{
int index = (wParam != ICON_SMALL) ? GCL_HICON : GCL_HICONSM;
return GetClassLongW(wndPtr->hwndSelf, index);
return GetClassLongW(hwnd, index);
}
case WM_HELP:
pSendMessage( wndPtr->parent->hwndSelf, msg, wParam, lParam );
SendMessageW( GetParent(hwnd), msg, wParam, lParam );
break;
}
@ -654,10 +654,9 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
LRESULT WINAPI DefWindowProc16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam,
LPARAM lParam )
{
WND * wndPtr = WIN_FindWndPtr( hwnd );
LRESULT result = 0;
if (!wndPtr) return 0;
if (!IsWindow( hwnd )) return 0;
SPY_EnterMessage( SPY_DEFWNDPROC16, hwnd, msg, wParam, lParam );
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)
* may have child window IDs instead of window name */
if (HIWORD(cs->lpszName))
DEFWND_SetTextA( wndPtr, MapSL(cs->lpszName) );
DEFWND_SetTextA( hwnd, MapSL(cs->lpszName) );
result = 1;
}
break;
@ -689,39 +688,20 @@ LRESULT WINAPI DefWindowProc16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam,
case WM_WINDOWPOSCHANGED:
{
WINDOWPOS16 * winPos = MapSL(lParam);
DEFWND_HandleWindowPosChanged( wndPtr, winPos->flags );
DEFWND_HandleWindowPosChanged( hwnd, winPos->flags );
}
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:
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:
DEFWND_SetTextA( wndPtr, MapSL(lParam) );
if( (wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION )
NC_HandleNCPaint( hwnd , (HRGN)1 );
result = 1; /* success. FIXME: check text length */
result = DefWindowProcA( hwnd, msg, wParam, (LPARAM)MapSL(lParam) );
break;
default:
result = DEFWND_DefWinProc( wndPtr, msg, wParam, lParam, FALSE );
result = DefWindowProcA( hwnd, msg, wParam, lParam );
break;
}
WIN_ReleaseWndPtr(wndPtr);
SPY_ExitMessage( SPY_RESULT_DEFWND16, hwnd, msg, result, wParam, lParam );
return result;
}
@ -731,13 +711,11 @@ LRESULT WINAPI DefWindowProc16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam,
* DefWindowProcA (USER32.@)
*
*/
LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam,
LPARAM lParam )
LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
WND * wndPtr = WIN_FindWndPtr( hwnd );
LRESULT result = 0;
if (!wndPtr) return 0;
if (!IsWindow( hwnd )) return 0;
SPY_EnterMessage( SPY_DEFWNDPROC, hwnd, msg, wParam, lParam );
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)
* may have child window IDs instead of window name */
if (HIWORD(cs->lpszName))
DEFWND_SetTextA( wndPtr, cs->lpszName );
DEFWND_SetTextA( hwnd, cs->lpszName );
result = 1;
}
break;
@ -764,29 +742,37 @@ LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam,
case WM_WINDOWPOSCHANGED:
{
WINDOWPOS * winPos = (WINDOWPOS *)lParam;
DEFWND_HandleWindowPosChanged( wndPtr, winPos->flags );
DEFWND_HandleWindowPosChanged( hwnd, winPos->flags );
}
break;
case WM_GETTEXTLENGTH:
if (wndPtr->text)
result = WideCharToMultiByte( CP_ACP, 0, wndPtr->text, strlenW(wndPtr->text),
NULL, 0, NULL, NULL );
{
WND *wndPtr = WIN_FindWndPtr( hwnd );
if (wndPtr && wndPtr->text)
result = WideCharToMultiByte( CP_ACP, 0, wndPtr->text, strlenW(wndPtr->text),
NULL, 0, NULL, NULL );
WIN_ReleaseWndPtr( wndPtr );
}
break;
case WM_GETTEXT:
if (wParam && wndPtr->text)
{
if (!WideCharToMultiByte( CP_ACP, 0, wndPtr->text, -1,
(LPSTR)lParam, wParam, NULL, NULL ))
((LPSTR)lParam)[wParam-1] = 0;
result = (LRESULT)strlen( (LPSTR)lParam );
WND *wndPtr = WIN_FindWndPtr( hwnd );
if (wParam && wndPtr && wndPtr->text)
{
LPSTR dest = (LPSTR)lParam;
if (!WideCharToMultiByte( CP_ACP, 0, wndPtr->text, -1,
dest, wParam, NULL, NULL )) dest[wParam-1] = 0;
result = strlen( dest );
}
WIN_ReleaseWndPtr( wndPtr );
}
break;
case WM_SETTEXT:
DEFWND_SetTextA( wndPtr, (LPCSTR)lParam );
if( (wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION )
DEFWND_SetTextA( hwnd, (LPCSTR)lParam );
if( (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CAPTION) == WS_CAPTION )
NC_HandleNCPaint( hwnd , (HRGN)1 ); /* Repaint caption */
result = 1; /* success. FIXME: check text length */
break;
@ -832,11 +818,10 @@ LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam,
break;
default:
result = DEFWND_DefWinProc( wndPtr, msg, wParam, lParam, FALSE );
result = DEFWND_DefWinProc( hwnd, msg, wParam, lParam );
break;
}
WIN_ReleaseWndPtr(wndPtr);
SPY_ExitMessage( SPY_RESULT_DEFWND, hwnd, msg, result, wParam, lParam );
return result;
}
@ -857,10 +842,9 @@ LRESULT WINAPI DefWindowProcW(
WPARAM wParam, /* [in] first message parameter */
LPARAM lParam ) /* [in] second message parameter */
{
WND * wndPtr = WIN_FindWndPtr( hwnd );
LRESULT result = 0;
if (!wndPtr) return 0;
if (!IsWindow( hwnd )) return 0;
SPY_EnterMessage( SPY_DEFWNDPROC, hwnd, msg, wParam, lParam );
switch(msg)
@ -871,7 +855,7 @@ LRESULT WINAPI DefWindowProcW(
/* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
* may have child window IDs instead of window name */
if (HIWORD(cs->lpszName))
DEFWND_SetTextW( wndPtr, cs->lpszName );
DEFWND_SetTextW( hwnd, cs->lpszName );
result = 1;
}
break;
@ -887,25 +871,34 @@ LRESULT WINAPI DefWindowProcW(
case WM_WINDOWPOSCHANGED:
{
WINDOWPOS * winPos = (WINDOWPOS *)lParam;
DEFWND_HandleWindowPosChanged( wndPtr, winPos->flags );
DEFWND_HandleWindowPosChanged( hwnd, winPos->flags );
}
break;
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;
case WM_GETTEXT:
if (wParam && wndPtr->text)
{
lstrcpynW( (LPWSTR)lParam, wndPtr->text, wParam );
result = strlenW( (LPWSTR)lParam );
WND *wndPtr = WIN_FindWndPtr( hwnd );
if (wParam && wndPtr && wndPtr->text)
{
LPWSTR dest = (LPWSTR)lParam;
lstrcpynW( dest, wndPtr->text, wParam );
result = strlenW( dest );
}
WIN_ReleaseWndPtr( wndPtr );
}
break;
case WM_SETTEXT:
DEFWND_SetTextW( wndPtr, (LPCWSTR)lParam );
if( (wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION )
DEFWND_SetTextW( hwnd, (LPCWSTR)lParam );
if( (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CAPTION) == WS_CAPTION )
NC_HandleNCPaint( hwnd , (HRGN)1 ); /* Repaint caption */
result = 1; /* success. FIXME: check text length */
break;
@ -925,10 +918,9 @@ LRESULT WINAPI DefWindowProcW(
break;
default:
result = DEFWND_DefWinProc( wndPtr, msg, wParam, lParam, TRUE );
result = DEFWND_DefWinProc( hwnd, msg, wParam, lParam );
break;
}
WIN_ReleaseWndPtr(wndPtr);
SPY_ExitMessage( SPY_RESULT_DEFWND, hwnd, msg, result, wParam, lParam );
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 )
{
WND *tmpWnd = WIN_FindWndPtr(hwnd);
/* pt has to be in the client coordinates of the parent window */
MapWindowPoints( 0, tmpWnd->hwndSelf, &pt, 1 );
while (tmpWnd)
MapWindowPoints( 0, hwnd, &pt, 1 );
for (;;)
{
if (!(tmpWnd->dwStyle & WS_CHILD) || (tmpWnd->dwExStyle & WS_EX_NOPARENTNOTIFY))
{
WIN_ReleaseWndPtr(tmpWnd);
break;
}
pt.x += tmpWnd->rectClient.left;
pt.y += tmpWnd->rectClient.top;
WIN_UpdateWndPtr(&tmpWnd,tmpWnd->parent);
SendMessageA( tmpWnd->hwndSelf, WM_PARENTNOTIFY,
HWND parent;
if (!(GetWindowLongA( hwnd, GWL_STYLE ) & WS_CHILD)) break;
if (GetWindowLongA( hwnd, GWL_EXSTYLE ) & WS_EX_NOPARENTNOTIFY) break;
if (!(parent = GetParent(hwnd))) break;
MapWindowPoints( hwnd, parent, &pt, 1 );
hwnd = parent;
SendMessageA( hwnd, WM_PARENTNOTIFY,
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 );
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;
@ -756,7 +756,7 @@ static HRGN RDW_Paint( WND* wndPtr, HRGN hrgn, UINT flags, UINT ex )
*/
HDC hDC;
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 ... */
@ -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)
&& ((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 (ppWnd = list; *ppWnd; ppWnd++)
for (phwnd = list; *phwnd; phwnd++)
{
WIN_UpdateWndPtr(&wndPtr,*ppWnd);
if (!IsWindow(wndPtr->hwndSelf)) continue;
if ( (wndPtr->dwStyle & WS_VISIBLE) &&
(wndPtr->hrgnUpdate || (wndPtr->flags & WIN_INTERNAL_PAINT)) )
hrgn = RDW_Paint( wndPtr, hrgn, flags, ex );
if (!(wndPtr = WIN_FindWndPtr( *phwnd ))) continue;
if ( (wndPtr->dwStyle & WS_VISIBLE) &&
(wndPtr->hrgnUpdate || (wndPtr->flags & WIN_INTERNAL_PAINT)) )
hrgn = RDW_Paint( wndPtr, hrgn, flags, ex );
WIN_ReleaseWndPtr(wndPtr);
}
WIN_ReleaseWndPtr(wndPtr);
WIN_ReleaseWinArray(list);
}
}

View File

@ -220,38 +220,32 @@ BOOL WINAPI ExitWindowsEx( UINT flags, DWORD reserved )
{
int i;
BOOL result;
WND **list, **ppWnd;
HWND *list, *phwnd;
/* We have to build a list of all windows first, as in EnumWindows */
if (!(list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL )))
{
WIN_ReleaseDesktop();
return FALSE;
}
if (!(list = WIN_BuildWinArray( GetDesktopWindow() ))) return FALSE;
/* 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 */
if (!IsWindow( (*ppWnd)->hwndSelf )) continue;
if (!SendMessageW( (*ppWnd)->hwndSelf, WM_QUERYENDSESSION, 0, 0 ))
break;
if (!IsWindow( list[i] )) continue;
if (!SendMessageW( list[i], WM_QUERYENDSESSION, 0, 0 )) break;
}
result = !(*ppWnd);
result = !list[i];
/* 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;
SendMessageW( (*ppWnd)->hwndSelf, WM_ENDSESSION, result, 0 );
if (!IsWindow( *phwnd )) continue;
SendMessageW( *phwnd, WM_ENDSESSION, result, 0 );
}
WIN_ReleaseWinArray(list);
if (result) ExitKernel16();
WIN_ReleaseDesktop();
return FALSE;
}

View File

@ -19,6 +19,7 @@
#include "hook.h"
#include "message.h"
#include "queue.h"
#include "task.h"
#include "winpos.h"
#include "winerror.h"
#include "stackframe.h"
@ -1096,7 +1097,8 @@ HWND WINAPI CreateWindowExW( DWORD exStyle, LPCWSTR className,
static void WIN_SendDestroyMsg( WND* pWnd )
{
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.
@ -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 */
@ -2544,50 +2547,53 @@ HWND16 WINAPI GetNextWindow16( HWND16 hwnd, WORD flag )
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 (!pWnd) return TRUE;
if (!win_array) return TRUE;
/*
* 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)
{
/* 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
*/
ShowWindow(pWnd[count]->hwndSelf,SW_SHOW);
pWnd[count]->flags &= ~WIN_NEEDS_INTERNALSOP; /* remove the flag */
ShowWindow(pWnd->hwndSelf,SW_SHOW);
pWnd->flags &= ~WIN_NEEDS_INTERNALSOP; /* remove the flag */
}
}
else
{
if ( IsWindowVisible(pWnd[count]->hwndSelf) && /* hide only if window is visible */
!( pWnd[count]->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 */
if ( IsWindowVisible(pWnd->hwndSelf) && /* hide only if window is visible */
!( pWnd->flags & WIN_NEEDS_INTERNALSOP ) && /* don't hide if previous call already did it */
!( 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
*/
ShowWindow(pWnd[count]->hwndSelf,SW_HIDE);
ShowWindow(pWnd->hwndSelf,SW_HIDE);
/* 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(pWnd);
WIN_ReleaseWinArray( win_array );
return TRUE;
}
@ -2605,45 +2611,48 @@ void WINAPI ShowOwnedPopups16( HWND16 owner, BOOL16 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 (pWnd[count]->flags & WIN_NEEDS_SHOW_OWNEDPOPUP)
if (pWnd->flags & WIN_NEEDS_SHOW_OWNEDPOPUP)
{
/*
* In Windows, ShowOwnedPopups(TRUE) generates WM_SHOWWINDOW messages with SW_PARENTOPENING,
/* In Windows, ShowOwnedPopups(TRUE) generates
* WM_SHOWWINDOW messages with SW_PARENTOPENING,
* regardless of the state of the owner
*/
SendMessageA(pWnd[count]->hwndSelf, WM_SHOWWINDOW, SW_SHOW, SW_PARENTOPENING);
pWnd[count]->flags &= ~WIN_NEEDS_SHOW_OWNEDPOPUP;
SendMessageA(pWnd->hwndSelf, WM_SHOWWINDOW, SW_SHOW, SW_PARENTOPENING);
pWnd->flags &= ~WIN_NEEDS_SHOW_OWNEDPOPUP;
}
}
else
{
if (IsWindowVisible(pWnd[count]->hwndSelf))
if (IsWindowVisible(pWnd->hwndSelf))
{
/*
* In Windows, ShowOwnedPopups(FALSE) generates WM_SHOWWINDOW messages with SW_PARENTCLOSING,
/* In Windows, ShowOwnedPopups(FALSE) generates
* WM_SHOWWINDOW messages with SW_PARENTCLOSING,
* regardless of the state of the owner
*/
SendMessageA(pWnd[count]->hwndSelf, WM_SHOWWINDOW, SW_HIDE, SW_PARENTCLOSING);
pWnd[count]->flags |= WIN_NEEDS_SHOW_OWNEDPOPUP;
SendMessageA(pWnd->hwndSelf, WM_SHOWWINDOW, SW_HIDE, SW_PARENTCLOSING);
pWnd->flags |= WIN_NEEDS_SHOW_OWNEDPOPUP;
}
}
}
WIN_ReleaseWndPtr( pWnd );
}
WIN_ReleaseDesktop();
WIN_ReleaseWinArray(pWnd);
WIN_ReleaseWinArray( win_array );
return TRUE;
}
@ -2679,31 +2688,21 @@ HWND WINAPI GetLastActivePopup( HWND hwnd )
* The array must be freed with WIN_ReleaseWinArray. Return NULL
* 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 */
WND **list, **ppWnd;
WND *pWnd;
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;
WND *pWnd, *wndPtr = WIN_FindWndPtr( hwnd );
HWND *list, *phwnd;
UINT count = 0;
/* First count the windows */
if (!wndPtr)
wndPtr = WIN_GetDesktop();
if (!wndPtr) return NULL;
pWnd = WIN_LockWndPtr(wndPtr->child);
while (pWnd)
{
if( !(pWnd->dwStyle & skipFlags) && !(skipOwned && pWnd->owner) &&
(!skipHidden || (pWnd->dwStyle & WS_VISIBLE)) )
count++;
count++;
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 */
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) );
else if( !skipHidden || pWnd->dwStyle & WS_VISIBLE )
{
*ppWnd++ = pWnd;
count++;
}
*phwnd++ = pWnd->hwndSelf;
count++;
}
WIN_ReleaseWndPtr(pWnd);
*ppWnd = NULL;
*phwnd = 0;
}
else count = 0;
} else list = NULL;
if( pTotal ) *pTotal = count;
WIN_ReleaseWndPtr( wndPtr );
return list;
}
/*******************************************************************
* WIN_ReleaseWinArray
*/
void WIN_ReleaseWinArray(WND **wndArray)
void WIN_ReleaseWinArray(HWND *wndArray)
{
/* Future: this function will also unlock all windows associated with wndArray */
HeapFree( GetProcessHeap(), 0, wndArray );
if (wndArray) HeapFree( GetProcessHeap(), 0, wndArray );
}
/*******************************************************************
@ -2746,82 +2740,28 @@ void WIN_ReleaseWinArray(WND **wndArray)
*/
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 */
/* unpleasant side-effects, for instance if the callback */
/* function changes the Z-order of the windows. */
if (!(list = WIN_BuildWinArray(WIN_GetDesktop(), 0, NULL )))
{
WIN_ReleaseDesktop();
return FALSE;
}
if (!(list = WIN_BuildWinArray( GetDesktopWindow() ))) return FALSE;
/* Now call the callback function for every window */
for (ppWnd = list; *ppWnd; ppWnd++)
iWndsLocks = WIN_SuspendWndsLock();
for (i = 0; list[i]; i++)
{
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();
lpEnumFuncRetval = lpEnumFunc( (*ppWnd)->hwndSelf, lParam);
WIN_RestoreWndsLock(iWndsLocks);
if (!lpEnumFuncRetval) break;
if (!IsWindow( list[i] )) continue;
if (!(ret = lpEnumFunc( list[i], lParam ))) break;
}
WIN_RestoreWndsLock(iWndsLocks);
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 */
if (!IsWindow((*ppWnd)->hwndSelf)) continue;
if ((*ppWnd)->hmemTaskQ != queue) 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();
funcRetval = func( (*ppWnd)->hwndSelf, lParam );
WIN_RestoreWndsLock(iWndsLocks);
if (!funcRetval) break;
}
WIN_ReleaseWinArray(list);
WIN_ReleaseDesktop();
return TRUE;
return ret;
}
@ -2831,9 +2771,9 @@ static BOOL WIN_EnumQueueWindows( HQUEUE16 queue, WNDENUMPROC func, LPARAM lPara
BOOL16 WINAPI EnumTaskWindows16( HTASK16 hTask, WNDENUMPROC16 func,
LPARAM lParam )
{
HQUEUE16 queue = GetTaskQueue16( hTask );
if (!queue) return FALSE;
return WIN_EnumQueueWindows( queue, (WNDENUMPROC)func, lParam );
TDB *tdb = TASK_GetPtr( hTask );
if (!tdb) return FALSE;
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 )
{
HQUEUE16 queue = GetThreadQueue16( id );
if (!queue) return FALSE;
return WIN_EnumQueueWindows( queue, func, lParam );
HWND *list;
int i, iWndsLocks;
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().
*/
static BOOL16 WIN_EnumChildWindows( WND **ppWnd, WNDENUMPROC func, LPARAM lParam )
static BOOL WIN_EnumChildWindows( HWND *list, WNDENUMPROC func, LPARAM lParam )
{
WND **childList;
BOOL16 ret = FALSE;
HWND *childList;
BOOL ret = FALSE;
for ( ; *ppWnd; ppWnd++)
for ( ; *list; list++)
{
int iWndsLocks = 0;
/* 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 */
childList = WIN_BuildWinArray( *ppWnd, BWA_SKIPOWNED, NULL );
/* 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();
ret = func( (*ppWnd)->hwndSelf, lParam );
WIN_RestoreWndsLock(iWndsLocks);
childList = WIN_BuildWinArray( *list );
ret = func( *list, lParam );
if (childList)
{
@ -2888,20 +2836,16 @@ static BOOL16 WIN_EnumChildWindows( WND **ppWnd, WNDENUMPROC func, LPARAM lParam
/**********************************************************************
* EnumChildWindows (USER32.@)
*/
BOOL WINAPI EnumChildWindows( HWND parent, WNDENUMPROC func,
LPARAM lParam )
BOOL WINAPI EnumChildWindows( HWND parent, WNDENUMPROC func, LPARAM lParam )
{
WND **list, *pParent;
HWND *list;
int iWndsLocks;
if (!(pParent = WIN_FindWndPtr( parent ))) return FALSE;
if (!(list = WIN_BuildWinArray( pParent, BWA_SKIPOWNED, NULL )))
{
WIN_ReleaseWndPtr(pParent);
return FALSE;
}
if (!(list = WIN_BuildWinArray( parent ))) return FALSE;
iWndsLocks = WIN_SuspendWndsLock();
WIN_EnumChildWindows( list, func, lParam );
WIN_RestoreWndsLock(iWndsLocks);
WIN_ReleaseWinArray(list);
WIN_ReleaseWndPtr(pParent);
return TRUE;
}
@ -3048,75 +2992,73 @@ BOOL WINAPI SetWindowContextHelpId( HWND hwnd, DWORD id )
*/
BOOL16 DRAG_QueryUpdate( HWND hQueryWnd, SEGPTR spDragInfo, BOOL bNoSend )
{
BOOL16 wParam, bResult = 0;
POINT pt;
LPDRAGINFO16 ptrDragInfo = MapSL(spDragInfo);
WND *ptrQueryWnd = WIN_FindWndPtr(hQueryWnd),*ptrWnd;
RECT tempRect;
BOOL16 wParam, bResult = 0;
POINT pt;
LPDRAGINFO16 ptrDragInfo = MapSL(spDragInfo);
RECT tempRect;
if( !ptrQueryWnd || !ptrDragInfo )
goto end;
if (!ptrDragInfo) return FALSE;
CONV_POINT16TO32( &ptrDragInfo->pt, &pt );
CONV_POINT16TO32( &ptrDragInfo->pt, &pt );
GetWindowRect(hQueryWnd,&tempRect);
GetWindowRect(hQueryWnd,&tempRect);
if( !PtInRect(&tempRect,pt) ||
(ptrQueryWnd->dwStyle & WS_DISABLED) )
goto end;
if( !PtInRect(&tempRect,pt) || !IsWindowEnabled(hQueryWnd)) return FALSE;
if( !(ptrQueryWnd->dwStyle & WS_MINIMIZE) )
{
tempRect = ptrQueryWnd->rectClient;
if(ptrQueryWnd->parent)
MapWindowPoints( ptrQueryWnd->parent->hwndSelf, 0,
(LPPOINT)&tempRect, 2 );
if (!IsIconic( hQueryWnd ))
{
WND *ptrWnd, *ptrQueryWnd = WIN_FindWndPtr(hQueryWnd);
if (PtInRect( &tempRect, pt))
{
wParam = 0;
for (ptrWnd = WIN_LockWndPtr(ptrQueryWnd->child); ptrWnd ;WIN_UpdateWndPtr(&ptrWnd,ptrWnd->next))
{
if( ptrWnd->dwStyle & WS_VISIBLE )
{
GetWindowRect( ptrWnd->hwndSelf, &tempRect );
if (PtInRect( &tempRect, pt )) break;
}
}
tempRect = ptrQueryWnd->rectClient;
if(ptrQueryWnd->parent)
MapWindowPoints( ptrQueryWnd->parent->hwndSelf, 0,
(LPPOINT)&tempRect, 2 );
if(ptrWnd)
{
TRACE_(msg)("hwnd = %04x, %d %d - %d %d\n",
ptrWnd->hwndSelf, ptrWnd->rectWindow.left, ptrWnd->rectWindow.top,
ptrWnd->rectWindow.right, ptrWnd->rectWindow.bottom );
if( !(ptrWnd->dwStyle & WS_DISABLED) )
bResult = DRAG_QueryUpdate(ptrWnd->hwndSelf, spDragInfo, bNoSend);
if (PtInRect( &tempRect, pt))
{
wParam = 0;
WIN_ReleaseWndPtr(ptrWnd);
}
for (ptrWnd = WIN_LockWndPtr(ptrQueryWnd->child); ptrWnd ;WIN_UpdateWndPtr(&ptrWnd,ptrWnd->next))
{
if( ptrWnd->dwStyle & WS_VISIBLE )
{
GetWindowRect( ptrWnd->hwndSelf, &tempRect );
if (PtInRect( &tempRect, pt )) break;
}
}
if(bResult)
goto end;
}
else wParam = 1;
}
else wParam = 1;
if(ptrWnd)
{
TRACE_(msg)("hwnd = %04x, %d %d - %d %d\n",
ptrWnd->hwndSelf, ptrWnd->rectWindow.left, ptrWnd->rectWindow.top,
ptrWnd->rectWindow.right, ptrWnd->rectWindow.bottom );
if( !(ptrWnd->dwStyle & WS_DISABLED) )
bResult = DRAG_QueryUpdate(ptrWnd->hwndSelf, spDragInfo, bNoSend);
ScreenToClient16(hQueryWnd,&ptrDragInfo->pt);
WIN_ReleaseWndPtr(ptrWnd);
}
ptrDragInfo->hScope = hQueryWnd;
if(bResult)
{
WIN_ReleaseWndPtr(ptrQueryWnd);
return bResult;
}
}
else wParam = 1;
WIN_ReleaseWndPtr(ptrQueryWnd);
}
else wParam = 1;
bResult = ( bNoSend )
? ptrQueryWnd->dwExStyle & WS_EX_ACCEPTFILES
: SendMessage16( hQueryWnd ,WM_QUERYDROPOBJECT ,
(WPARAM16)wParam ,(LPARAM) spDragInfo );
if( !bResult )
CONV_POINT32TO16( &pt, &ptrDragInfo->pt );
ScreenToClient16(hQueryWnd,&ptrDragInfo->pt);
end:
WIN_ReleaseWndPtr(ptrQueryWnd);
return bResult;
ptrDragInfo->hScope = hQueryWnd;
if (bNoSend) bResult = (GetWindowLongA( hQueryWnd, GWL_EXSTYLE ) & WS_EX_ACCEPTFILES) != 0;
else bResult = SendMessage16( hQueryWnd, WM_QUERYDROPOBJECT, (WPARAM16)wParam, spDragInfo );
if( !bResult ) CONV_POINT32TO16( &pt, &ptrDragInfo->pt );
return bResult;
}
@ -3183,25 +3125,17 @@ DWORD WINAPI DragObject16( HWND16 hwndScope, HWND16 hWnd, UINT16 wObj,
SEGPTR spDragInfo;
HCURSOR16 hDragCursor=0, hOldCursor=0, hBummer=0;
HGLOBAL16 hDragInfo = GlobalAlloc16( GMEM_SHARE | GMEM_ZEROINIT, 2*sizeof(DRAGINFO16));
WND *wndPtr = WIN_FindWndPtr(hWnd);
HCURSOR16 hCurrentCursor = 0;
HWND16 hCurrentWnd = 0;
lpDragInfo = (LPDRAGINFO16) GlobalLock16(hDragInfo);
spDragInfo = K32WOWGlobalLock16(hDragInfo);
if( !lpDragInfo || !spDragInfo )
{
WIN_ReleaseWndPtr(wndPtr);
return 0L;
}
if( !lpDragInfo || !spDragInfo ) return 0L;
hBummer = LoadCursorA(0, MAKEINTRESOURCEA(OCR_NO));
if( !hBummer || !wndPtr )
if (!(hBummer = LoadCursorA(0, MAKEINTRESOURCEA(OCR_NO))))
{
GlobalFree16(hDragInfo);
WIN_ReleaseWndPtr(wndPtr);
return 0L;
}
@ -3210,7 +3144,6 @@ DWORD WINAPI DragObject16( HWND16 hwndScope, HWND16 hWnd, UINT16 wObj,
if( !(hDragCursor = CURSORICON_IconToCursor(hCursor, FALSE)) )
{
GlobalFree16(hDragInfo);
WIN_ReleaseWndPtr(wndPtr);
return 0L;
}
@ -3232,8 +3165,7 @@ DWORD WINAPI DragObject16( HWND16 hwndScope, HWND16 hWnd, UINT16 wObj,
do
{
do{ WaitMessage(); }
while( !PeekMessageA(&msg,0,WM_MOUSEFIRST,WM_MOUSELAST,PM_REMOVE) );
GetMessageW( &msg, 0, WM_MOUSEFIRST, WM_MOUSELAST );
*(lpDragInfo+1) = *lpDragInfo;
@ -3288,7 +3220,6 @@ DWORD WINAPI DragObject16( HWND16 hwndScope, HWND16 hWnd, UINT16 wObj,
else
msg.lParam = 0;
GlobalFree16(hDragInfo);
WIN_ReleaseWndPtr(wndPtr);
return (DWORD)(msg.lParam);
}

View File

@ -1570,37 +1570,33 @@ BOOL WINPOS_SetActiveWindow( HWND hWnd, BOOL fMouse, BOOL fChangeFocus)
/* send WM_ACTIVATEAPP if necessary */
if (hOldActiveQueue != hNewActiveQueue)
{
WND **list, **ppWnd;
WND *pDesktop = WIN_GetDesktop();
HWND *list, *phwnd;
DWORD old_thread = GetWindowThreadProcessId( hwndPrevActive, NULL );
DWORD new_thread = GetWindowThreadProcessId( hwndActive, NULL );
if ((list = WIN_BuildWinArray( pDesktop, 0, NULL )))
if ((list = WIN_BuildWinArray( GetDesktopWindow() )))
{
DWORD new_thread = GetWindowThreadProcessId( hwndActive, NULL );
for (ppWnd = list; *ppWnd; ppWnd++)
for (phwnd = list; *phwnd; phwnd++)
{
if (!IsWindow( (*ppWnd)->hwndSelf )) continue;
if ((*ppWnd)->hmemTaskQ == hOldActiveQueue)
SendMessageW( (*ppWnd)->hwndSelf, WM_ACTIVATEAPP, 0, new_thread );
if (!IsWindow( *phwnd )) continue;
if (GetWindowThreadProcessId( *phwnd, NULL ) == old_thread)
SendMessageW( *phwnd, WM_ACTIVATEAPP, 0, new_thread );
}
WIN_ReleaseWinArray(list);
}
hActiveQueue = hNewActiveQueue;
if ((list = WIN_BuildWinArray(pDesktop, 0, NULL )))
if ((list = WIN_BuildWinArray( GetDesktopWindow() )))
{
DWORD old_thread = GetWindowThreadProcessId( hwndPrevActive, NULL );
for (ppWnd = list; *ppWnd; ppWnd++)
for (phwnd = list; *phwnd; phwnd++)
{
if (!IsWindow( (*ppWnd)->hwndSelf )) continue;
if ((*ppWnd)->hmemTaskQ == hNewActiveQueue)
SendMessageW( (*ppWnd)->hwndSelf, WM_ACTIVATEAPP, 1, old_thread );
if (!IsWindow( *phwnd )) continue;
if (GetWindowThreadProcessId( *phwnd, NULL ) == new_thread)
SendMessageW( *phwnd, WM_ACTIVATEAPP, 1, old_thread );
}
WIN_ReleaseWinArray(list);
}
WIN_ReleaseDesktop();
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
* 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();
HWND hWndClipOwner = 0;
Window XWnd = get_whole_window(pWnd);
HWND tmp;
Window XWnd = X11DRV_get_whole_window(hwnd);
Atom xaClipboard;
BOOL bLostSelection = FALSE;
@ -1141,11 +1142,8 @@ void X11DRV_ResetSelectionOwner(WND *pWnd, BOOL bFooBar)
selectionPrevWindow = selectionWindow;
selectionWindow = None;
if( pWnd->next )
selectionWindow = get_whole_window(pWnd->next);
else if( pWnd->parent )
if( pWnd->parent->child != pWnd )
selectionWindow = get_whole_window(pWnd->parent->child);
if (!(tmp = GetWindow( hwnd, GW_HWNDNEXT ))) tmp = GetWindow( hwnd, GW_HWNDFIRST );
if (tmp && tmp != hwnd) selectionWindow = X11DRV_get_whole_window(tmp);
if( selectionWindow != None )
{