Commit 6b1b41cf authored by Francois Boisvert's avatar Francois Boisvert Committed by Alexandre Julliard

Made access to the wnd struct thread-safe.

parent 2e1cafa2
......@@ -79,6 +79,7 @@ LRESULT WINAPI ButtonWndProc( HWND hWnd, UINT uMsg,
WPARAM wParam, LPARAM lParam )
{
RECT rect;
LRESULT retvalue;
POINT pt = { LOWORD(lParam), HIWORD(lParam) };
WND *wndPtr = WIN_FindWndPtr(hWnd);
BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
......@@ -87,6 +88,7 @@ LRESULT WINAPI ButtonWndProc( HWND hWnd, UINT uMsg,
switch (uMsg)
{
case WM_GETDLGCODE:
WIN_ReleaseWndPtr(wndPtr);
switch(style)
{
case BS_PUSHBUTTON: return DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON;
......@@ -109,12 +111,18 @@ LRESULT WINAPI ButtonWndProc( HWND hWnd, UINT uMsg,
checkBoxWidth = bmp.bmWidth / 4;
checkBoxHeight = bmp.bmHeight / 3;
}
if (style < 0L || style >= MAX_BTN_TYPE) return -1; /* abort */
if (style < 0L || style >= MAX_BTN_TYPE)
{
WIN_ReleaseWndPtr(wndPtr);
return -1; /* abort */
}
infoPtr->state = BUTTON_UNCHECKED;
infoPtr->hFont = 0;
WIN_ReleaseWndPtr(wndPtr);
return 0;
case WM_ERASEBKGND:
WIN_ReleaseWndPtr(wndPtr);
return 1;
case WM_PAINT:
......@@ -171,6 +179,7 @@ LRESULT WINAPI ButtonWndProc( HWND hWnd, UINT uMsg,
break;
case WM_NCHITTEST:
WIN_ReleaseWndPtr(wndPtr);
if(style == BS_GROUPBOX) return HTTRANSPARENT;
return DefWindowProcA( hWnd, uMsg, wParam, lParam );
......@@ -178,6 +187,7 @@ LRESULT WINAPI ButtonWndProc( HWND hWnd, UINT uMsg,
DEFWND_SetText( wndPtr, (LPCSTR)lParam );
if( wndPtr->dwStyle & WS_VISIBLE )
PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
WIN_ReleaseWndPtr(wndPtr);
return 0;
case WM_SETFONT:
......@@ -187,7 +197,9 @@ LRESULT WINAPI ButtonWndProc( HWND hWnd, UINT uMsg,
break;
case WM_GETFONT:
return infoPtr->hFont;
retvalue = infoPtr->hFont;
WIN_ReleaseWndPtr(wndPtr);
return retvalue;
case WM_SETFOCUS:
infoPtr->state |= BUTTON_HASFOCUS;
......@@ -219,7 +231,9 @@ LRESULT WINAPI ButtonWndProc( HWND hWnd, UINT uMsg,
case BM_GETCHECK16:
case BM_GETCHECK:
return infoPtr->state & 3;
retvalue = infoPtr->state & 3;
WIN_ReleaseWndPtr(wndPtr);
return retvalue;
case BM_SETCHECK16:
case BM_SETCHECK:
......@@ -242,7 +256,9 @@ LRESULT WINAPI ButtonWndProc( HWND hWnd, UINT uMsg,
case BM_GETSTATE16:
case BM_GETSTATE:
return infoPtr->state;
retvalue = infoPtr->state;
WIN_ReleaseWndPtr(wndPtr);
return retvalue;
case BM_SETSTATE16:
case BM_SETSTATE:
......@@ -260,8 +276,10 @@ LRESULT WINAPI ButtonWndProc( HWND hWnd, UINT uMsg,
break;
default:
WIN_ReleaseWndPtr(wndPtr);
return DefWindowProcA(hWnd, uMsg, wParam, lParam);
}
WIN_ReleaseWndPtr(wndPtr);
return 0;
}
......@@ -522,11 +540,14 @@ static void BUTTON_CheckAutoRadioButton( WND *wndPtr )
start = sibling = GetNextDlgGroupItem( parent, wndPtr->hwndSelf, TRUE );
do
{
WND *tmpWnd;
if (!sibling) break;
tmpWnd = WIN_FindWndPtr(sibling);
if ((wndPtr->hwndSelf != sibling) &&
((WIN_FindWndPtr(sibling)->dwStyle & 0x0f) == BS_AUTORADIOBUTTON))
((tmpWnd->dwStyle & 0x0f) == BS_AUTORADIOBUTTON))
SendMessageA( sibling, BM_SETCHECK, BUTTON_UNCHECKED, 0 );
sibling = GetNextDlgGroupItem( parent, sibling, FALSE );
WIN_ReleaseWndPtr(tmpWnd);
} while (sibling != start);
}
......
......@@ -24,8 +24,12 @@
*/
int DESKTOP_GetScreenWidth()
{
int retvalue;
DESKTOP *pDesktop = (DESKTOP *) WIN_GetDesktop()->wExtra;
return MONITOR_GetWidth(pDesktop->pPrimaryMonitor);
retvalue = MONITOR_GetWidth(pDesktop->pPrimaryMonitor);
WIN_ReleaseDesktop();
return retvalue;
}
/***********************************************************************
......@@ -35,8 +39,12 @@ int DESKTOP_GetScreenWidth()
*/
int DESKTOP_GetScreenHeight()
{
int retvalue;
DESKTOP *pDesktop = (DESKTOP *) WIN_GetDesktop()->wExtra;
return MONITOR_GetHeight(pDesktop->pPrimaryMonitor);
retvalue = MONITOR_GetHeight(pDesktop->pPrimaryMonitor);
WIN_ReleaseDesktop();
return retvalue;
}
/***********************************************************************
......@@ -46,8 +54,12 @@ int DESKTOP_GetScreenHeight()
*/
int DESKTOP_GetScreenDepth()
{
int retvalue;
DESKTOP *pDesktop = (DESKTOP *) WIN_GetDesktop()->wExtra;
return MONITOR_GetDepth(pDesktop->pPrimaryMonitor);
retvalue = MONITOR_GetDepth(pDesktop->pPrimaryMonitor);
WIN_ReleaseDesktop();
return retvalue;
}
/***********************************************************************
......@@ -119,6 +131,8 @@ static LRESULT DESKTOP_DoEraseBkgnd( HWND hwnd, HDC hdc,
if (Wnd->hrgnUpdate > 1) DeleteObject( Wnd->hrgnUpdate );
Wnd->hrgnUpdate = 0;
WIN_ReleaseWndPtr(Wnd);
GetClientRect( hwnd, &rect );
/* Paint desktop pattern (only if wall paper does not cover everything) */
......@@ -173,6 +187,7 @@ static LRESULT DESKTOP_DoEraseBkgnd( HWND hwnd, HDC hdc,
LRESULT WINAPI DesktopWndProc( HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam )
{
LRESULT retvalue;
WND *wndPtr = WIN_FindWndPtr( hwnd );
DESKTOP *desktopPtr = (DESKTOP *)wndPtr->wExtra;
......@@ -187,23 +202,36 @@ LRESULT WINAPI DesktopWndProc( HWND hwnd, UINT message,
desktopPtr->hbitmapWallPaper = 0;
SetDeskPattern();
SetDeskWallPaper( (LPSTR)-1 );
return 1;
retvalue = 1;
goto END;
case WM_ERASEBKGND:
if (X11DRV_WND_GetXRootWindow(wndPtr) ==
DefaultRootWindow(display))
return 1;
return DESKTOP_DoEraseBkgnd( hwnd, (HDC)wParam, desktopPtr );
{
retvalue = 1;
goto END;
}
retvalue = DESKTOP_DoEraseBkgnd( hwnd, (HDC)wParam, desktopPtr );
goto END;
case WM_SYSCOMMAND:
if ((wParam & 0xfff0) != SC_CLOSE) return 0;
if ((wParam & 0xfff0) != SC_CLOSE)
{
retvalue = 0;
goto END;
}
ExitWindows16( 0, 0 );
case WM_SETCURSOR:
return (LRESULT)SetCursor16( LoadCursor16( 0, IDC_ARROW16 ) );
retvalue = (LRESULT)SetCursor16( LoadCursor16( 0, IDC_ARROW16 ) );
goto END;
}
return 0;
retvalue = 0;
END:
WIN_ReleaseWndPtr(wndPtr);
return retvalue;
}
/***********************************************************************
......@@ -212,11 +240,14 @@ LRESULT WINAPI DesktopWndProc( HWND hwnd, UINT message,
*/
BOOL WINAPI PaintDesktop(HDC hdc)
{
BOOL retvalue;
HWND hwnd = GetDesktopWindow();
WND *wndPtr = WIN_FindWndPtr( hwnd );
DESKTOP *desktopPtr = (DESKTOP *)wndPtr->wExtra;
retvalue = DESKTOP_DoEraseBkgnd( hwnd, hdc, desktopPtr );
WIN_ReleaseWndPtr(wndPtr);
return retvalue;
return DESKTOP_DoEraseBkgnd( hwnd, hdc, desktopPtr );
}
/***********************************************************************
......@@ -270,6 +301,7 @@ BOOL WINAPI SetDeskWallPaper( LPCSTR filename )
desktopPtr->bitmapSize.cx = (bmp.bmWidth != 0) ? bmp.bmWidth : 1;
desktopPtr->bitmapSize.cy = (bmp.bmHeight != 0) ? bmp.bmHeight : 1;
}
WIN_ReleaseDesktop();
return TRUE;
}
......@@ -301,6 +333,7 @@ BOOL DESKTOP_SetPattern( LPCSTR pattern )
DeleteObject( hbitmap );
}
else desktopPtr->hbrushPattern = CreateSolidBrush( GetSysColor(COLOR_BACKGROUND) );
WIN_ReleaseDesktop();
return TRUE;
}
......@@ -310,15 +310,21 @@ LRESULT WINAPI EditWndProc( HWND hwnd, UINT msg,
case WM_DESTROY:
DPRINTF_EDIT_MSG32("WM_DESTROY");
EDIT_WM_Destroy(wnd, es);
return 0;
result = 0;
goto END;
case WM_NCCREATE:
DPRINTF_EDIT_MSG32("WM_NCCREATE");
return EDIT_WM_NCCreate(wnd, (LPCREATESTRUCTA)lParam);
result = EDIT_WM_NCCreate(wnd, (LPCREATESTRUCTA)lParam);
goto END;
}
if (!es)
return DefWindowProcA(hwnd, msg, wParam, lParam);
{
result = DefWindowProcA(hwnd, msg, wParam, lParam);
goto END;
}
EDIT_LockBuffer(wnd, es);
switch (msg) {
......@@ -633,7 +639,7 @@ LRESULT WINAPI EditWndProc( HWND hwnd, UINT msg,
wnd->dwStyle &= ~ES_READONLY;
es->style &= ~ES_READONLY;
}
return 1;
result = 1;
break;
case EM_SETWORDBREAKPROC16:
......@@ -856,7 +862,10 @@ LRESULT WINAPI EditWndProc( HWND hwnd, UINT msg,
break;
}
EDIT_UnlockBuffer(wnd, es, FALSE);
END:
WIN_ReleaseWndPtr(wnd);
return result;
}
......
......@@ -54,6 +54,7 @@ HWND ICONTITLE_Create( WND* wnd )
wndPtr->owner = wnd; /* MDI depends on this */
wndPtr->dwStyle &= ~(WS_CAPTION | WS_BORDER);
if( wnd->dwStyle & WS_DISABLED ) wndPtr->dwStyle |= WS_DISABLED;
WIN_ReleaseWndPtr(wndPtr);
return hWnd;
}
return 0;
......@@ -187,24 +188,25 @@ static BOOL ICONTITLE_Paint( WND* wnd, HDC hDC, BOOL bActive )
LRESULT WINAPI IconTitleWndProc( HWND hWnd, UINT msg,
WPARAM wParam, LPARAM lParam )
{
LRESULT retvalue;
WND *wnd = WIN_FindWndPtr( hWnd );
switch( msg )
{
case WM_NCHITTEST:
return HTCAPTION;
retvalue = HTCAPTION;
goto END;
case WM_NCMOUSEMOVE:
case WM_NCLBUTTONDBLCLK:
return SendMessageA( wnd->owner->hwndSelf, msg, wParam, lParam );
retvalue = SendMessageA( wnd->owner->hwndSelf, msg, wParam, lParam );
goto END;
case WM_ACTIVATE:
if( wParam ) SetActiveWindow( wnd->owner->hwndSelf );
/* fall through */
case WM_CLOSE:
return 0;
retvalue = 0;
goto END;
case WM_SHOWWINDOW:
if( wnd && wParam )
{
......@@ -220,25 +222,30 @@ LRESULT WINAPI IconTitleWndProc( HWND hWnd, UINT msg,
titleRect.right, titleRect.bottom,
SWP_NOACTIVATE | SWP_NOZORDER );
}
return 0;
retvalue = 0;
goto END;
case WM_ERASEBKGND:
if( wnd )
{
WND* iconWnd = wnd->owner;
WND* iconWnd = WIN_LockWndPtr(wnd->owner);
if( iconWnd->dwStyle & WS_CHILD )
lParam = SendMessageA( iconWnd->hwndSelf, WM_ISACTIVEICON, 0, 0 );
else
lParam = (iconWnd->hwndSelf == GetActiveWindow16());
WIN_ReleaseWndPtr(iconWnd);
if( ICONTITLE_Paint( wnd, (HDC)wParam, (BOOL)lParam ) )
ValidateRect( hWnd, NULL );
return 1;
retvalue = 1;
goto END;
}
}
return DefWindowProcA( hWnd, msg, wParam, lParam );
retvalue = DefWindowProcA( hWnd, msg, wParam, lParam );
END:
WIN_ReleaseWndPtr(wnd);
return retvalue;
}
......@@ -146,8 +146,11 @@ static SCROLLBAR_INFO *SCROLL_GetPtrScrollInfo( WND* wndPtr, INT nBar )
*/
static SCROLLBAR_INFO *SCROLL_GetScrollInfo( HWND hwnd, INT nBar )
{
SCROLLBAR_INFO *retvalue;
WND *wndPtr = WIN_FindWndPtr( hwnd );
return SCROLL_GetPtrScrollInfo( wndPtr, nBar );
retvalue = SCROLL_GetPtrScrollInfo( wndPtr, nBar );
WIN_ReleaseWndPtr(wndPtr);
return retvalue;
}
......@@ -204,6 +207,7 @@ static BOOL SCROLL_GetScrollBarRect( HWND hwnd, INT nBar, RECT *lprect,
break;
default:
WIN_ReleaseWndPtr(wndPtr);
return FALSE;
}
......@@ -248,6 +252,7 @@ static BOOL SCROLL_GetScrollBarRect( HWND hwnd, INT nBar, RECT *lprect,
+ pixels * (info->CurVal-info->MinVal) / (max - info->MinVal);
}
}
WIN_ReleaseWndPtr(wndPtr);
return vertical;
}
......@@ -560,8 +565,8 @@ void SCROLL_DrawScrollBar( HWND hwnd, HDC hdc, INT nBar,
if (!wndPtr || !infoPtr ||
((nBar == SB_VERT) && !(wndPtr->dwStyle & WS_VSCROLL)) ||
((nBar == SB_HORZ) && !(wndPtr->dwStyle & WS_HSCROLL))) return;
if (!WIN_IsWindowDrawable( wndPtr, FALSE )) return;
((nBar == SB_HORZ) && !(wndPtr->dwStyle & WS_HSCROLL))) goto END;
if (!WIN_IsWindowDrawable( wndPtr, FALSE )) goto END;
vertical = SCROLL_GetScrollBarRect( hwnd, nBar, &rect,
&arrowSize, &thumbSize, &thumbPos );
......@@ -581,6 +586,8 @@ void SCROLL_DrawScrollBar( HWND hwnd, HDC hdc, INT nBar,
if( interior )
SCROLL_DrawInterior( hwnd, hdc, nBar, &rect, arrowSize, thumbSize,
thumbPos, infoPtr->flags, vertical, FALSE, FALSE );
END:
WIN_ReleaseWndPtr(wndPtr);
}
......@@ -621,11 +628,13 @@ static void SCROLL_HandleKbdEvent( HWND hwnd, WPARAM wParam )
case VK_UP: msg = SB_LINEUP; break;
case VK_DOWN: msg = SB_LINEDOWN; break;
default:
WIN_ReleaseWndPtr(wndPtr);
return;
}
SendMessageA( GetParent(hwnd),
(wndPtr->dwStyle & SBS_VERT) ? WM_VSCROLL : WM_HSCROLL,
msg, hwnd );
WIN_ReleaseWndPtr(wndPtr);
}
......@@ -1383,6 +1392,7 @@ BOOL SCROLL_ShowScrollBar( HWND hwnd, INT nBar,
BOOL fShowH, BOOL fShowV )
{
WND *wndPtr = WIN_FindWndPtr( hwnd );
BOOL retvalue = FALSE;
if (!wndPtr) return FALSE;
TRACE(scroll, "hwnd=%04x bar=%d horz=%d, vert=%d\n",
......@@ -1392,7 +1402,8 @@ BOOL SCROLL_ShowScrollBar( HWND hwnd, INT nBar,
{
case SB_CTL:
ShowWindow( hwnd, fShowH ? SW_SHOW : SW_HIDE );
return TRUE;
retvalue = TRUE;
goto END;
case SB_BOTH:
case SB_HORZ:
......@@ -1423,17 +1434,22 @@ BOOL SCROLL_ShowScrollBar( HWND hwnd, INT nBar,
break;
default:
return FALSE; /* Nothing to do! */
retvalue = FALSE; /* Nothing to do! */
goto END;
}
if( fShowH || fShowV ) /* frame has been changed, let the window redraw itself */
{
SetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE
| SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
return TRUE;
retvalue = TRUE;
goto END;
}
return FALSE; /* no frame changes */
retvalue = FALSE; /* no frame changes */
END:
WIN_ReleaseWndPtr(wndPtr);
return retvalue;
}
......
......@@ -182,12 +182,14 @@ LRESULT WINAPI StaticWndProc( HWND hWnd, UINT uMsg, WPARAM wParam,
if (style == SS_ICON)
{
if (cs->lpszName) {
if (cs->lpszName)
{
if (!HIWORD(cs->lpszName) || cs->lpszName[0])
STATIC_SetIcon( wndPtr,
STATIC_LoadIcon( wndPtr, cs->lpszName ));
}
return 1;
lResult = 1;
goto END;
}
if (style == SS_BITMAP)
{
......@@ -196,15 +198,18 @@ LRESULT WINAPI StaticWndProc( HWND hWnd, UINT uMsg, WPARAM wParam,
STATIC_LoadBitmap( wndPtr, cs->lpszName ));
WARN(static, "style SS_BITMAP, dwStyle is 0x%08lx\n",
wndPtr->dwStyle);
return 1;
lResult = 1;
goto END;
}
if (!HIWORD(cs->lpszName) && (cs->lpszName)) {
if (!HIWORD(cs->lpszName) && (cs->lpszName))
{
FIXME(static,"windowName is 0x%04x, not doing DefWindowProc\n",
LOWORD(cs->lpszName)
);
return 1;
LOWORD(cs->lpszName));
lResult = 1;
goto END;
}
return DefWindowProcA( hWnd, uMsg, wParam, lParam );
lResult = DefWindowProcA( hWnd, uMsg, wParam, lParam );
goto END;
}
case WM_CREATE:
if (style < 0L || style > SS_TYPEMASK)
......@@ -268,8 +273,16 @@ LRESULT WINAPI StaticWndProc( HWND hWnd, UINT uMsg, WPARAM wParam,
break;
case WM_SETFONT:
if (style == SS_ICON) return 0;
if (style == SS_BITMAP) return 0;
if (style == SS_ICON)
{
lResult = 0;
goto END;
}
if (style == SS_BITMAP)
{
lResult = 0;
goto END;
}
infoPtr->hFont = (HFONT16)wParam;
if (LOWORD(lParam))
{
......@@ -279,18 +292,22 @@ LRESULT WINAPI StaticWndProc( HWND hWnd, UINT uMsg, WPARAM wParam,
break;
case WM_GETFONT:
return infoPtr->hFont;
lResult = infoPtr->hFont;
goto END;
case WM_NCHITTEST:
return HTTRANSPARENT;
lResult = HTTRANSPARENT;
goto END;
case WM_GETDLGCODE:
return DLGC_STATIC;
lResult = DLGC_STATIC;
goto END;
case STM_GETIMAGE:
case STM_GETICON16:
case STM_GETICON:
return infoPtr->hIcon;
lResult = infoPtr->hIcon;
goto END;
case STM_SETIMAGE:
/* FIXME: handle wParam */
......@@ -311,6 +328,8 @@ LRESULT WINAPI StaticWndProc( HWND hWnd, UINT uMsg, WPARAM wParam,
break;
}
END:
WIN_ReleaseWndPtr(wndPtr);
return lResult;
}
......
......@@ -682,8 +682,12 @@ LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam,
break;
/*If we released the mouse and our buddy is an edit */
/* we must select all text in it. */
if(WIDGETS_IsControl(WIN_FindWndPtr(infoPtr->Buddy), BIC32_EDIT))
SendMessageA(infoPtr->Buddy, EM_SETSEL, 0, MAKELONG(0, -1));
{
WND *tmpWnd = WIN_FindWndPtr(infoPtr->Buddy);
if(WIDGETS_IsControl(tmpWnd, BIC32_EDIT))
SendMessageA(infoPtr->Buddy, EM_SETSEL, 0, MAKELONG(0, -1));
WIN_ReleaseWndPtr(tmpWnd);
}
break;
case WM_LBUTTONDOWN:
......
......@@ -2671,7 +2671,11 @@ static HRESULT WINAPI IDirectDraw2_SetCooperativeLevel(
/* This will be overwritten in the case of Full Screen mode.
Windowed games could work with that :-) */
if (hwnd)
this->d.drawable = X11DRV_WND_GetXWindow(WIN_FindWndPtr(hwnd));
{
WND *tmpWnd = WIN_FindWndPtr(hwnd);
this->d.drawable = X11DRV_WND_GetXWindow(tmpWnd);
WIN_ReleaseWndPtr(tmpWnd);
}
return DD_OK;
}
......@@ -2985,6 +2989,7 @@ static HRESULT WINAPI Xlib_IDirectDraw_SetDisplayMode(
LPDIRECTDRAW this,DWORD width,DWORD height,DWORD depth
) {
char buf[200];
WND *tmpWnd;
TRACE(ddraw, "(%p)->SetDisplayMode(%ld,%ld,%ld)\n",
this, width, height, depth);
......@@ -3062,11 +3067,17 @@ static HRESULT WINAPI Xlib_IDirectDraw_SetDisplayMode(
_common_IDirectDraw_SetDisplayMode(this);
tmpWnd = WIN_FindWndPtr(this->d.window);
this->d.paintable = 1;
this->d.drawable = ((X11DRV_WND_DATA *) WIN_FindWndPtr(this->d.window)->pDriverData)->window;
this->d.drawable = ((X11DRV_WND_DATA *) tmpWnd->pDriverData)->window;
/* We don't have a context for this window. Host off the desktop */
if( !this->d.drawable )
{
this->d.drawable = ((X11DRV_WND_DATA *) WIN_GetDesktop()->pDriverData)->window;
WIN_ReleaseDesktop();
}
WIN_ReleaseWndPtr(tmpWnd);
return DD_OK;
}
......@@ -4068,11 +4079,15 @@ LRESULT WINAPI Xlib_DDWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
if( !ret )
{
WND *tmpWnd =WIN_FindWndPtr(ddraw->d.mainWindow);
/* We didn't handle the message - give it to the application */
if (ddraw && ddraw->d.mainWindow && WIN_FindWndPtr(ddraw->d.mainWindow)) {
ret = CallWindowProcA( WIN_FindWndPtr( ddraw->d.mainWindow )->winproc,
if (ddraw && ddraw->d.mainWindow && tmpWnd)
{
ret = CallWindowProcA(tmpWnd->winproc,
ddraw->d.mainWindow, msg, wParam, lParam );
}
WIN_ReleaseWndPtr(tmpWnd);
}
} else {
......@@ -4223,10 +4238,14 @@ HRESULT WINAPI DirectDrawCreate( LPGUID lpGUID, LPDIRECTDRAW *lplpDD, LPUNKNOWN
sizeof( LPDIRECTDRAW ); /* ddrawXlibThisOffset */
/* We can be a child of the desktop since we're really important */
/*
This code is not useful since hInstance is forced to 0 afterward
pParentWindow = WIN_GetDesktop();
wc.hInstance = pParentWindow ? pParentWindow->hwndSelf : 0;
*/
wc.hInstance = 0;
wc.hIcon = 0;
wc.hCursor = (HCURSOR)IDC_ARROWA;
wc.hbrBackground= NULL_BRUSH;
......
......@@ -273,6 +273,8 @@ static LRESULT WINAPI THUNK_CallWndProc16( WNDPROC16 proc, HWND16 hwnd,
EBP_reg(&context) = OFFSETOF(thdb->cur_stack)
+ (WORD)&((STACK16FRAME*)0)->bp;
WIN_ReleaseWndPtr(wndPtr);
if (lParam)
{
/* Some programs (eg. the "Undocumented Windows" examples, JWP) only
......
......@@ -139,8 +139,11 @@ extern void WIN_UnlockWnds();
extern int WIN_SuspendWndsLock();
extern void WIN_RestoreWndsLock(int ipreviousLock);
extern WND* WIN_FindWndPtr( HWND hwnd );
extern WND* WIN_LockWndPtr(WND *wndPtr);
extern void WIN_ReleaseWndPtr(WND *wndPtr);
extern void WIN_UpdateWndPtr(WND **oldPtr,WND *newPtr);
extern WND* WIN_GetDesktop(void);
extern void WIN_ReleaseDesktop(void);
extern void WIN_DumpWindow( HWND hwnd );
extern void WIN_WalkWindows( HWND hwnd, int indent );
extern BOOL WIN_UnlinkWindow( HWND hwnd );
......@@ -153,6 +156,7 @@ extern WND* WIN_GetTopParentPtr( WND* pWnd );
extern BOOL WIN_IsWindowDrawable(WND*, BOOL );
extern HINSTANCE WIN_GetWindowInstance( HWND hwnd );
extern WND** WIN_BuildWinArray( WND *wndPtr, UINT bwa, UINT* pnum );
extern void WIN_ReleaseWinArray(WND **wndArray);
extern HWND CARET_GetHwnd(void);
extern void CARET_GetRect(LPRECT lprc); /* windows/caret.c */
......
......@@ -462,7 +462,7 @@ int DDE_GetRemoteMessage()
/* iterate through all the windows */
for (wndPtr = WIN_FindWndPtr(GetTopWindow(GetDesktopWindow()));
wndPtr != NULL;
wndPtr = wndPtr->next)
WIN_UpdateWndPtr(&wndPtr,wndPtr->next))
{
if (wndPtr->dwStyle & WS_POPUP || wndPtr->dwStyle & WS_CAPTION) {
if (was_sent)
......
......@@ -653,6 +653,8 @@ const char *SPY_GetWndName( HWND hwnd )
if( *src ) for( n = 0; n < 3; n++ ) *(p++)='.';
*(p++) = postfix;
*(p++) = '\0';
WIN_ReleaseWndPtr(pWnd);
}
else lstrcpyA( wnd_buffer, "\"NULL\"" );
return wnd_buffer;
......
......@@ -728,7 +728,11 @@ WORD WINAPI GetClassWord( HWND hwnd, INT offset )
if (offset >= 0)
{
if (offset <= wndPtr->class->cbClsExtra - sizeof(WORD))
return GET_WORD(((char *)wndPtr->class->wExtra) + offset);
{
WORD retvalue = GET_WORD(((char *)wndPtr->class->wExtra) + offset);
WIN_ReleaseWndPtr(wndPtr);
return retvalue;
}
}
else switch(offset)
{
......@@ -741,9 +745,11 @@ WORD WINAPI GetClassWord( HWND hwnd, INT offset )
case GCW_CBWNDEXTRA:
case GCW_CBCLSEXTRA:
case GCW_HMODULE:
WIN_ReleaseWndPtr(wndPtr);
return (WORD)GetClassLongA( hwnd, offset );
}
WIN_ReleaseWndPtr(wndPtr);
WARN(class, "Invalid offset %d\n", offset);
return 0;
}
......@@ -763,7 +769,9 @@ LONG WINAPI GetClassLong16( HWND16 hwnd, INT16 offset )
{
case GCL_WNDPROC:
if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
return (LONG)WINPROC_GetProc( wndPtr->class->winproc, WIN_PROC_16 );
ret = (LONG)WINPROC_GetProc( wndPtr->class->winproc, WIN_PROC_16 );
WIN_ReleaseWndPtr(wndPtr);
return ret;
case GCL_MENUNAME:
ret = GetClassLongA( hwnd, offset );
return (LONG)SEGPTR_GET( (void *)ret );
......@@ -779,6 +787,7 @@ LONG WINAPI GetClassLong16( HWND16 hwnd, INT16 offset )
LONG WINAPI GetClassLongA( HWND hwnd, INT offset )
{
WND * wndPtr;
LONG retvalue;
TRACE(class,"%x %x\n",hwnd, offset);
......@@ -786,27 +795,41 @@ LONG WINAPI GetClassLongA( HWND hwnd, INT offset )
if (offset >= 0)
{
if (offset <= wndPtr->class->cbClsExtra - sizeof(LONG))
return GET_DWORD(((char *)wndPtr->class->wExtra) + offset);
{
retvalue = GET_DWORD(((char *)wndPtr->class->wExtra) + offset);
goto END;
}
}
switch(offset)
{
case GCL_STYLE: return (LONG)wndPtr->class->style;
case GCL_CBWNDEXTRA: return (LONG)wndPtr->class->cbWndExtra;
case GCL_CBCLSEXTRA: return (LONG)wndPtr->class->cbClsExtra;
case GCL_HMODULE: return (LONG)wndPtr->class->hInstance;
case GCL_STYLE: retvalue = (LONG)wndPtr->class->style;
goto END;
case GCL_CBWNDEXTRA: retvalue = (LONG)wndPtr->class->cbWndExtra;
goto END;
case GCL_CBCLSEXTRA: retvalue = (LONG)wndPtr->class->cbClsExtra;
goto END;
case GCL_HMODULE: retvalue = (LONG)wndPtr->class->hInstance;
goto END;
case GCL_WNDPROC:
return (LONG)WINPROC_GetProc(wndPtr->class->winproc, WIN_PROC_32A);
retvalue = (LONG)WINPROC_GetProc(wndPtr->class->winproc, WIN_PROC_32A);
goto END;
case GCL_MENUNAME:
return (LONG)CLASS_GetMenuNameA( wndPtr->class );
retvalue = (LONG)CLASS_GetMenuNameA( wndPtr->class );
goto END;
case GCW_ATOM:
case GCL_HBRBACKGROUND:
case GCL_HCURSOR:
case GCL_HICON:
case GCL_HICONSM:
return GetClassWord( hwnd, offset );
retvalue = GetClassWord( hwnd, offset );
goto END;
}
WARN(class, "Invalid offset %d\n", offset);
return 0;
retvalue = 0;
END:
WIN_ReleaseWndPtr(wndPtr);
return retvalue;
}
......@@ -816,6 +839,7 @@ LONG WINAPI GetClassLongA( HWND hwnd, INT offset )
LONG WINAPI GetClassLongW( HWND hwnd, INT offset )
{
WND * wndPtr;
LONG retvalue;
TRACE(class,"%x %x\n",hwnd, offset);
......@@ -823,10 +847,14 @@ LONG WINAPI GetClassLongW( HWND hwnd, INT offset )
{
case GCL_WNDPROC:
if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
return (LONG)WINPROC_GetProc( wndPtr->class->winproc, WIN_PROC_32W );
retvalue = (LONG)WINPROC_GetProc( wndPtr->class->winproc, WIN_PROC_32W );
WIN_ReleaseWndPtr(wndPtr);
return retvalue;
case GCL_MENUNAME:
if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
return (LONG)CLASS_GetMenuNameW( wndPtr->class );
retvalue = (LONG)CLASS_GetMenuNameW( wndPtr->class );
WIN_ReleaseWndPtr(wndPtr);
return retvalue;
default:
return GetClassLongA( hwnd, offset );
}
......@@ -861,6 +889,7 @@ WORD WINAPI SetClassWord( HWND hwnd, INT offset, WORD newval )
else
{
WARN( class, "Invalid offset %d\n", offset );
WIN_ReleaseWndPtr(wndPtr);
return 0;
}
}
......@@ -870,6 +899,7 @@ WORD WINAPI SetClassWord( HWND hwnd, INT offset, WORD newval )
case GCW_CBWNDEXTRA:
case GCW_CBCLSEXTRA:
case GCW_HMODULE:
WIN_ReleaseWndPtr(wndPtr);
return (WORD)SetClassLongA( hwnd, offset, (LONG)newval );
case GCW_HBRBACKGROUND: ptr = &wndPtr->class->hbrBackground; break;
case GCW_HCURSOR: ptr = &wndPtr->class->hCursor; break;
......@@ -878,6 +908,7 @@ WORD WINAPI SetClassWord( HWND hwnd, INT offset, WORD newval )
case GCW_ATOM: ptr = &wndPtr->class->atomName; break;
default:
WARN( class, "Invalid offset %d\n", offset);
WIN_ReleaseWndPtr(wndPtr);
return 0;
}
retval = GET_WORD(ptr);
......@@ -892,6 +923,7 @@ WORD WINAPI SetClassWord( HWND hwnd, INT offset, WORD newval )
CLASS_SetClassNameA( wndPtr->class, NULL );
FIXME(class,"GCW_ATOM changed for a class. Not updating className, so GetClassInfoEx may not return correct className!\n");
}
WIN_ReleaseWndPtr(wndPtr);
return retval;
}
......@@ -913,6 +945,7 @@ LONG WINAPI SetClassLong16( HWND16 hwnd, INT16 offset, LONG newval )
retval = (LONG)WINPROC_GetProc( wndPtr->class->winproc, WIN_PROC_16 );
WINPROC_SetProc( &wndPtr->class->winproc, (WNDPROC16)newval,
WIN_PROC_16, WIN_PROC_CLASS );
WIN_ReleaseWndPtr(wndPtr);
return retval;
case GCL_MENUNAME:
return SetClassLongA( hwnd, offset, (LONG)PTR_SEG_TO_LIN(newval) );
......@@ -941,35 +974,41 @@ LONG WINAPI SetClassLongA( HWND hwnd, INT offset, LONG newval )
else
{
WARN( class, "Invalid offset %d\n", offset );
return 0;
retval = 0;
goto END;
}
}
else switch(offset)
{
case GCL_MENUNAME:
CLASS_SetMenuNameA( wndPtr->class, (LPCSTR)newval );
return 0; /* Old value is now meaningless anyway */
retval = 0; /* Old value is now meaningless anyway */
goto END;
case GCL_WNDPROC:
retval = (LONG)WINPROC_GetProc( wndPtr->class->winproc,
WIN_PROC_32A );
WINPROC_SetProc( &wndPtr->class->winproc, (WNDPROC16)newval,
WIN_PROC_32A, WIN_PROC_CLASS );
return retval;
goto END;
case GCL_HBRBACKGROUND:
case GCL_HCURSOR:
case GCL_HICON:
case GCL_HICONSM:
return SetClassWord( hwnd, offset, (WORD)newval );
retval = SetClassWord( hwnd, offset, (WORD)newval );
goto END;
case GCL_STYLE: ptr = &wndPtr->class->style; break;
case GCL_CBWNDEXTRA: ptr = &wndPtr->class->cbWndExtra; break;
case GCL_CBCLSEXTRA: ptr = &wndPtr->class->cbClsExtra; break;
case GCL_HMODULE: ptr = &wndPtr->class->hInstance; break;
default:
WARN( class, "Invalid offset %d\n", offset );
return 0;
retval = 0;
goto END;
}
retval = GET_DWORD(ptr);
PUT_DWORD( ptr, newval );
END:
WIN_ReleaseWndPtr(wndPtr);
return retval;
}
......@@ -991,10 +1030,12 @@ LONG WINAPI SetClassLongW( HWND hwnd, INT offset, LONG newval )
retval = (LONG)WINPROC_GetProc( wndPtr->class->winproc, WIN_PROC_32W );
WINPROC_SetProc( &wndPtr->class->winproc, (WNDPROC16)newval,
WIN_PROC_32W, WIN_PROC_CLASS );
WIN_ReleaseWndPtr(wndPtr);
return retval;
case GCL_MENUNAME:
if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
CLASS_SetMenuNameW( wndPtr->class, (LPCWSTR)newval );
WIN_ReleaseWndPtr(wndPtr);
return 0; /* Old value is now meaningless anyway */
default:
return SetClassLongA( hwnd, offset, newval );
......@@ -1008,8 +1049,11 @@ LONG WINAPI SetClassLongW( HWND hwnd, INT offset, LONG newval )
INT16 WINAPI GetClassName16( HWND16 hwnd, LPSTR buffer, INT16 count )
{
WND *wndPtr;
INT16 retvalue;
if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
return GlobalGetAtomName16( wndPtr->class->atomName, buffer, count );
retvalue = GlobalGetAtomName16( wndPtr->class->atomName, buffer, count );
WIN_ReleaseWndPtr(wndPtr);
return retvalue;
}
......@@ -1023,6 +1067,7 @@ INT WINAPI GetClassNameA( HWND hwnd, LPSTR buffer, INT count )
if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
ret = GlobalGetAtomNameA( wndPtr->class->atomName, buffer, count );
WIN_ReleaseWndPtr(wndPtr);
TRACE(class,"%x %s %x\n",hwnd, buffer, count);
return ret;
}
......@@ -1037,7 +1082,7 @@ INT WINAPI GetClassNameW( HWND hwnd, LPWSTR buffer, INT count )
if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
ret = GlobalGetAtomNameW( wndPtr->class->atomName, buffer, count );
WIN_ReleaseWndPtr(wndPtr);
TRACE(class,"%x %s %x\n",hwnd, debugstr_w(buffer), count);
return ret;
......
......@@ -91,6 +91,8 @@ DCE *DCE_AllocDCE( HWND hWnd, DCE_TYPE type )
if( wnd->dwStyle & WS_CLIPCHILDREN ) dce->DCXflags |= DCX_CLIPCHILDREN;
if( wnd->dwStyle & WS_CLIPSIBLINGS ) dce->DCXflags |= DCX_CLIPSIBLINGS;
WIN_ReleaseWndPtr(wnd);
}
SetHookFlags16(dce->hDC,DCHF_INVALIDATEVISRGN);
}
......@@ -248,14 +250,18 @@ BOOL DCE_InvalidateDCE(WND* pWnd, const RECT* pRectUpdate)
if( wndCurrent && wndCurrent != WIN_GetDesktop() )
{
WND* wnd = wndCurrent;
WND* wnd = NULL;
INT xoffset = 0, yoffset = 0;
if( (wndCurrent == wndScope) && !(dce->DCXflags & DCX_CLIPCHILDREN) ) continue;
if( (wndCurrent == wndScope) && !(dce->DCXflags & DCX_CLIPCHILDREN) )
{
WIN_ReleaseWndPtr(wndCurrent);
continue;
}
/* check if DCE window is within the z-order scope */
for( wnd = wndCurrent; wnd; wnd = wnd->parent )
for( wnd = WIN_LockWndPtr(wndCurrent); wnd; WIN_UpdateWndPtr(&wnd,wnd->parent))
{
if( wnd == wndScope )
{
......@@ -298,6 +304,8 @@ BOOL DCE_InvalidateDCE(WND* pWnd, const RECT* pRectUpdate)
yoffset += wnd->rectClient.top;
}
}
WIN_ReleaseWndPtr(wndCurrent);
WIN_ReleaseDesktop();
}
} /* dce list */
}
......@@ -338,10 +346,13 @@ static BOOL DCE_GetVisRect( WND *wndPtr, BOOL clientArea, RECT *lprect )
while (wndPtr->dwStyle & WS_CHILD)
{
wndPtr = wndPtr->parent;
wndPtr = WIN_LockWndPtr(wndPtr->parent);
if ( (wndPtr->dwStyle & (WS_ICONIC | WS_VISIBLE)) != WS_VISIBLE )
{
WIN_ReleaseWndPtr(wndPtr);
goto fail;
}
xoffset += wndPtr->rectClient.left;
yoffset += wndPtr->rectClient.top;
......@@ -354,12 +365,17 @@ static BOOL DCE_GetVisRect( WND *wndPtr, BOOL clientArea, RECT *lprect )
(lprect->right <= wndPtr->rectClient.left) ||
(lprect->top >= wndPtr->rectClient.bottom) ||
(lprect->bottom <= wndPtr->rectClient.top) )
{
WIN_ReleaseWndPtr(wndPtr);
goto fail;
}
lprect->left = MAX( lprect->left, wndPtr->rectClient.left );
lprect->right = MIN( lprect->right, wndPtr->rectClient.right );
lprect->top = MAX( lprect->top, wndPtr->rectClient.top );
lprect->bottom = MIN( lprect->bottom, wndPtr->rectClient.bottom );
WIN_ReleaseWndPtr(wndPtr);
}
OffsetRect( lprect, -xoffset, -yoffset );
return TRUE;
......@@ -386,9 +402,13 @@ static BOOL DCE_AddClipRects( WND *pWndStart, WND *pWndEnd,
if( pWndStart->pDriver->pIsSelfClipping( pWndStart ) )
return TRUE; /* The driver itself will do the clipping */
for (; pWndStart != pWndEnd; pWndStart = pWndStart->next)
for (; pWndStart != pWndEnd; pWndStart = WIN_LockWndPtr(pWndStart->next))
{
if( !(pWndStart->dwStyle & WS_VISIBLE) ) continue;
if( !(pWndStart->dwStyle & WS_VISIBLE) )
{
WIN_ReleaseWndPtr(pWndStart);
continue;
}
rect.left = pWndStart->rectWindow.left + x;
rect.top = pWndStart->rectWindow.top + y;
......@@ -397,8 +417,12 @@ static BOOL DCE_AddClipRects( WND *pWndStart, WND *pWndEnd,
if( IntersectRect( &rect, &rect, lpRect ))
if(!REGION_UnionRectWithRgn( hrgnClip, &rect ))
{
WIN_ReleaseWndPtr(pWndStart);
break;
}
WIN_ReleaseWndPtr(pWndStart);
}
return (pWndStart == pWndEnd);
}
......@@ -500,7 +524,7 @@ HRGN DCE_GetVisRgn( HWND hwnd, WORD flags, HWND hwndChild, WORD cflags )
while (wndPtr->dwStyle & WS_CHILD)
{
wndPtr = wndPtr->parent;
WIN_UpdateWndPtr(&wndPtr,wndPtr->parent);
xoffset -= wndPtr->rectClient.left;
yoffset -= wndPtr->rectClient.top;
if(wndPtr->dwStyle & WS_CLIPSIBLINGS && wndPtr->parent)
......@@ -526,6 +550,8 @@ HRGN DCE_GetVisRgn( HWND hwnd, WORD flags, HWND hwndChild, WORD cflags )
}
else
hrgnVis = CreateRectRgn(0, 0, 0, 0); /* empty */
WIN_ReleaseWndPtr(wndPtr);
WIN_ReleaseWndPtr(childWnd);
return hrgnVis;
}
......@@ -565,6 +591,7 @@ INT16 DCE_ExcludeRgn( HDC hDC, WND* wnd, HRGN hRgn )
wnd = WIN_FindWndPtr(dce->hwndCurrent);
pt.x += wnd->rectClient.left - wnd->rectWindow.left;
pt.y += wnd->rectClient.top - wnd->rectWindow.top;
WIN_ReleaseWndPtr(wnd);
}
}
else return ERROR;
......@@ -719,14 +746,22 @@ HDC WINAPI GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags )
}
}
}
if (!dce) return 0;
if (!dce)
{
hdc = 0;
goto END;
}
dce->hwndCurrent = hwnd;
dce->hClipRgn = 0;
dce->DCXflags = dcxFlags | (flags & DCX_WINDOWPAINT) | DCX_DCEBUSY;
hdc = dce->hDC;
if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return 0;
if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC )))
{
hdc = 0;
goto END;
}
bUpdateVisRgn = bUpdateVisRgn || (dc->w.flags & DC_DIRTY);
/* recompute visible region */
......@@ -738,7 +773,7 @@ HDC WINAPI GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags )
if (flags & DCX_PARENTCLIP)
{
WND *parentPtr = wndPtr->parent;
WND *parentPtr = WIN_LockWndPtr(wndPtr->parent);
if( wndPtr->dwStyle & WS_VISIBLE && !(parentPtr->dwStyle & WS_MINIMIZE) )
{
......@@ -759,6 +794,7 @@ HDC WINAPI GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags )
}
else
hrgnVisible = CreateRectRgn( 0, 0, 0, 0 );
WIN_ReleaseWndPtr(parentPtr);
}
else
if ((hwnd == GetDesktopWindow()) &&
......@@ -801,6 +837,8 @@ HDC WINAPI GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags )
TRACE(dc, "(%04x,%04x,0x%lx): returning %04x\n",
hwnd, hrgnClip, flags, hdc);
END:
WIN_ReleaseWndPtr(wndPtr);
return hdc;
}
......
......@@ -215,6 +215,7 @@ static LRESULT DEFDLG_Proc( HWND hwnd, UINT msg, WPARAM wParam,
SendMessageA( wnd->parent->hwndSelf,
CB_SHOWDROPDOWN, FALSE, 0 );
}
WIN_ReleaseWndPtr(wnd);
}
}
return DefWindowProcA( hwnd, msg, wParam, lParam );
......@@ -287,6 +288,7 @@ 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:
......@@ -296,9 +298,11 @@ 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);
}
......@@ -344,6 +348,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 );
case WM_INITDIALOG:
......@@ -353,9 +358,11 @@ 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);
}
......@@ -401,6 +408,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 );
case WM_INITDIALOG:
......@@ -410,8 +418,10 @@ 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);
}
......@@ -306,6 +306,7 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
wndPtr = WIN_FindWndPtr( hWnd );
if( wndPtr && !(wndPtr->class->style & CS_NOCLOSE) )
PostMessage16( hWnd, WM_SYSCOMMAND, SC_CLOSE, 0 );
WIN_ReleaseWndPtr(wndPtr);
}
}
else if( wParam == VK_F10 )
......@@ -358,6 +359,7 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
case WM_CANCELMODE:
if (wndPtr->parent == WIN_GetDesktop()) EndMenu();
if (GetCapture() == wndPtr->hwndSelf) ReleaseCapture();
WIN_ReleaseDesktop();
break;
case WM_VKEYTOITEM:
......@@ -458,6 +460,7 @@ LRESULT WINAPI DefWindowProc16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam,
break;
}
WIN_ReleaseWndPtr(wndPtr);
SPY_ExitMessage( SPY_RESULT_DEFWND16, hwnd, msg, result );
return result;
}
......@@ -520,6 +523,7 @@ LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam,
break;
}
WIN_ReleaseWndPtr(wndPtr);
SPY_ExitMessage( SPY_RESULT_DEFWND, hwnd, msg, result );
return result;
}
......@@ -553,6 +557,7 @@ LRESULT WINAPI DefWindowProcW(
LPSTR str = HEAP_strdupWtoA(GetProcessHeap(), 0, cs->lpszName);
DEFWND_SetText( wndPtr, str );
HeapFree( GetProcessHeap(), 0, str );
WIN_ReleaseWndPtr(wndPtr);
}
result = 1;
}
......
......@@ -707,9 +707,10 @@ HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCSTR dlgTemplate,
ShowWindow( hwnd, SW_SHOWNORMAL ); /* SW_SHOW doesn't always work */
UpdateWindow( hwnd );
}
WIN_ReleaseWndPtr(wndPtr);
return hwnd;
}
WIN_ReleaseWndPtr(wndPtr);
if( IsWindow(hwnd) ) DestroyWindow( hwnd );
return 0;
}
......@@ -874,6 +875,7 @@ INT DIALOG_DoDialogBox( HWND hwnd, HWND owner )
EnableWindow( owner, TRUE );
}
retval = dlgInfo->idResult;
WIN_ReleaseWndPtr(wndPtr);
DestroyWindow( hwnd );
return retval;
}
......@@ -1005,6 +1007,7 @@ BOOL WINAPI EndDialog( HWND hwnd, INT retval )
dlgInfo->idResult = retval;
dlgInfo->flags |= DF_END;
}
WIN_ReleaseWndPtr(wndPtr);
return TRUE;
}
......@@ -1086,6 +1089,7 @@ static BOOL DIALOG_IsAccelerator( HWND hwnd, HWND hwndDlg, WPARAM vKey )
{
hwndNext = 0;
}
WIN_ReleaseWndPtr(wndPtr);
if (!hwndNext)
{
hwndNext = GetWindow( hwndControl, GW_HWNDNEXT );
......@@ -1294,8 +1298,13 @@ BOOL WINAPI IsDialogMessageW( HWND hwndDlg, LPMSG msg )
INT16 WINAPI GetDlgCtrlID16( HWND16 hwnd )
{
WND *wndPtr = WIN_FindWndPtr(hwnd);
if (wndPtr) return wndPtr->wIDmenu;
else return 0;
INT16 retvalue;
if (!wndPtr) return 0;
retvalue = wndPtr->wIDmenu;
WIN_ReleaseWndPtr(wndPtr);
return retvalue;
}
......@@ -1304,9 +1313,12 @@ INT16 WINAPI GetDlgCtrlID16( HWND16 hwnd )
*/
INT WINAPI GetDlgCtrlID( HWND hwnd )
{
INT retvalue;
WND *wndPtr = WIN_FindWndPtr(hwnd);
if (wndPtr) return wndPtr->wIDmenu;
else return 0;
if (!wndPtr) return 0;
retvalue = wndPtr->wIDmenu;
WIN_ReleaseWndPtr(wndPtr);
return retvalue;
}
......@@ -1318,8 +1330,13 @@ HWND16 WINAPI GetDlgItem16( HWND16 hwndDlg, INT16 id )
WND *pWnd;
if (!(pWnd = WIN_FindWndPtr( hwndDlg ))) return 0;
for (pWnd = pWnd->child; pWnd; pWnd = pWnd->next)
if (pWnd->wIDmenu == (UINT16)id) return pWnd->hwndSelf;
for (WIN_UpdateWndPtr(&pWnd,pWnd->child); pWnd; WIN_UpdateWndPtr(&pWnd,pWnd->next))
if (pWnd->wIDmenu == (UINT16)id)
{
HWND16 retvalue = pWnd->hwndSelf;
WIN_ReleaseWndPtr(pWnd);
return retvalue;
}
return 0;
}
......@@ -1332,8 +1349,13 @@ HWND WINAPI GetDlgItem( HWND hwndDlg, INT id )
WND *pWnd;
if (!(pWnd = WIN_FindWndPtr( hwndDlg ))) return 0;
for (pWnd = pWnd->child; pWnd; pWnd = pWnd->next)
if (pWnd->wIDmenu == (UINT16)id) return pWnd->hwndSelf;
for (WIN_UpdateWndPtr(&pWnd,pWnd->child); pWnd;WIN_UpdateWndPtr(&pWnd,pWnd->next))
if (pWnd->wIDmenu == (UINT16)id)
{
HWND retvalue = pWnd->hwndSelf;
WIN_ReleaseWndPtr(pWnd);
return retvalue;
}
return 0;
}
......@@ -1570,8 +1592,12 @@ BOOL WINAPI CheckRadioButton( HWND hwndDlg, UINT firstID,
WND *pWnd = WIN_FindWndPtr( hwndDlg );
if (!pWnd) return FALSE;
for (pWnd = pWnd->child; pWnd; pWnd = pWnd->next)
if ((pWnd->wIDmenu == firstID) || (pWnd->wIDmenu == lastID)) break;
for (WIN_UpdateWndPtr(&pWnd,pWnd->child); pWnd;WIN_UpdateWndPtr(&pWnd,pWnd->next))
if ((pWnd->wIDmenu == firstID) || (pWnd->wIDmenu == lastID))
{
WIN_ReleaseWndPtr(pWnd);
break;
}
if (!pWnd) return FALSE;
if (pWnd->wIDmenu == lastID)
......@@ -1580,8 +1606,12 @@ BOOL WINAPI CheckRadioButton( HWND hwndDlg, UINT firstID,
{
SendMessageA( pWnd->hwndSelf, BM_SETCHECK,
(pWnd->wIDmenu == checkID), 0 );
if (pWnd->wIDmenu == lastID) break;
pWnd = pWnd->next;
if (pWnd->wIDmenu == lastID)
{
WIN_ReleaseWndPtr(pWnd);
break;
}
WIN_UpdateWndPtr(&pWnd,pWnd->next);
}
return TRUE;
}
......@@ -1609,6 +1639,7 @@ void WINAPI MapDialogRect16( HWND16 hwnd, LPRECT16 rect )
rect->right = (rect->right * dlgInfo->xBaseUnit) / 4;
rect->top = (rect->top * dlgInfo->yBaseUnit) / 8;
rect->bottom = (rect->bottom * dlgInfo->yBaseUnit) / 8;
WIN_ReleaseWndPtr(wndPtr);
}
......@@ -1625,6 +1656,7 @@ BOOL WINAPI MapDialogRect( HWND hwnd, LPRECT rect )
rect->right = (rect->right * dlgInfo->xBaseUnit) / 4;
rect->top = (rect->top * dlgInfo->yBaseUnit) / 8;
rect->bottom = (rect->bottom * dlgInfo->yBaseUnit) / 8;
WIN_ReleaseWndPtr(wndPtr);
return TRUE;
}
......@@ -1645,33 +1677,51 @@ HWND16 WINAPI GetNextDlgGroupItem16( HWND16 hwndDlg, HWND16 hwndCtrl,
HWND WINAPI GetNextDlgGroupItem( HWND hwndDlg, HWND hwndCtrl,
BOOL fPrevious )
{
WND *pWnd, *pWndLast, *pWndCtrl, *pWndDlg;
WND *pWnd = NULL,
*pWndLast = NULL,
*pWndCtrl = NULL,
*pWndDlg = NULL;
HWND retvalue;
if (!(pWndDlg = WIN_FindWndPtr( hwndDlg ))) return 0;
if (hwndCtrl)
{
if (!(pWndCtrl = WIN_FindWndPtr( hwndCtrl ))) return 0;
if (!(pWndCtrl = WIN_FindWndPtr( hwndCtrl )))
{
retvalue = 0;
goto END;
}
/* Make sure hwndCtrl is a top-level child */
while ((pWndCtrl->dwStyle & WS_CHILD) && (pWndCtrl->parent != pWndDlg))
pWndCtrl = pWndCtrl->parent;
if (pWndCtrl->parent != pWndDlg) return 0;
WIN_UpdateWndPtr(&pWndCtrl,pWndCtrl->parent);
if (pWndCtrl->parent != pWndDlg)
{
retvalue = 0;
goto END;
}
}
else
{
/* No ctrl specified -> start from the beginning */
if (!(pWndCtrl = pWndDlg->child)) return 0;
if (fPrevious) while (pWndCtrl->next) pWndCtrl = pWndCtrl->next;
if (!(pWndCtrl = WIN_LockWndPtr(pWndDlg->child)))
{
retvalue = 0;
goto END;
}
if (fPrevious)
while (pWndCtrl->next) WIN_UpdateWndPtr(&pWndCtrl,pWndCtrl->next);
}
pWndLast = pWndCtrl;
pWnd = pWndCtrl->next;
pWndLast = WIN_LockWndPtr(pWndCtrl);
pWnd = WIN_LockWndPtr(pWndCtrl->next);
while (1)
{
if (!pWnd || (pWnd->dwStyle & WS_GROUP))
{
/* Wrap-around to the beginning of the group */
WND *pWndStart = pWndDlg->child;
for (pWnd = pWndStart; pWnd; pWnd = pWnd->next)
WND *pWndStart = WIN_LockWndPtr(pWndDlg->child);
for (WIN_UpdateWndPtr(&pWnd,pWndStart); pWnd;WIN_UpdateWndPtr(&pWnd,pWnd->next))
{
if (pWnd->dwStyle & WS_GROUP) pWndStart = pWnd;
if (pWnd == pWndCtrl) break;
......@@ -1681,12 +1731,20 @@ HWND WINAPI GetNextDlgGroupItem( HWND hwndDlg, HWND hwndCtrl,
if (pWnd == pWndCtrl) break;
if ((pWnd->dwStyle & WS_VISIBLE) && !(pWnd->dwStyle & WS_DISABLED))
{
pWndLast = pWnd;
WIN_UpdateWndPtr(&pWndLast,pWnd);
if (!fPrevious) break;
}
pWnd = pWnd->next;
WIN_UpdateWndPtr(&pWnd,pWnd->next);
}
return pWndLast->hwndSelf;
retvalue = pWndLast->hwndSelf;
WIN_ReleaseWndPtr(pWndLast);
WIN_ReleaseWndPtr(pWnd);
END:
WIN_ReleaseWndPtr(pWndCtrl);
WIN_ReleaseWndPtr(pWndDlg);
return retvalue;
}
......@@ -1706,39 +1764,61 @@ HWND16 WINAPI GetNextDlgTabItem16( HWND16 hwndDlg, HWND16 hwndCtrl,
HWND WINAPI GetNextDlgTabItem( HWND hwndDlg, HWND hwndCtrl,
BOOL fPrevious )
{
WND *pWnd, *pWndLast, *pWndCtrl, *pWndDlg;
WND *pWnd = NULL,
*pWndLast = NULL,
*pWndCtrl = NULL,
*pWndDlg = NULL;
HWND retvalue;
if (!(pWndDlg = WIN_FindWndPtr( hwndDlg ))) return 0;
if (hwndCtrl)
{
if (!(pWndCtrl = WIN_FindWndPtr( hwndCtrl ))) return 0;
if (!(pWndCtrl = WIN_FindWndPtr( hwndCtrl )))
{
retvalue = 0;
goto END;
}
/* Make sure hwndCtrl is a top-level child */
while ((pWndCtrl->dwStyle & WS_CHILD) && (pWndCtrl->parent != pWndDlg))
pWndCtrl = pWndCtrl->parent;
if (pWndCtrl->parent != pWndDlg) return 0;
WIN_UpdateWndPtr(&pWndCtrl,pWndCtrl->parent);
if (pWndCtrl->parent != pWndDlg)
{
retvalue = 0;
goto END;
}
}
else
{
/* No ctrl specified -> start from the beginning */
if (!(pWndCtrl = pWndDlg->child)) return 0;
if (!fPrevious) while (pWndCtrl->next) pWndCtrl = pWndCtrl->next;
if (!(pWndCtrl = WIN_LockWndPtr(pWndDlg->child))) return 0;
if (!fPrevious)
while (pWndCtrl->next) WIN_UpdateWndPtr(&pWndCtrl,pWndCtrl->next);
}
pWndLast = pWndCtrl;
pWnd = pWndCtrl->next;
pWndLast = WIN_LockWndPtr(pWndCtrl);
pWnd = WIN_LockWndPtr(pWndCtrl->next);
while (1)
{
if (!pWnd) pWnd = pWndDlg->child;
if (!pWnd) pWnd = WIN_LockWndPtr(pWndDlg->child);
if (pWnd == pWndCtrl) break;
if ((pWnd->dwStyle & WS_TABSTOP) && (pWnd->dwStyle & WS_VISIBLE) &&
!(pWnd->dwStyle & WS_DISABLED))
{
pWndLast = pWnd;
WIN_UpdateWndPtr(&pWndLast,pWnd);
if (!fPrevious) break;
}
pWnd = pWnd->next;
WIN_UpdateWndPtr(&pWnd,pWnd->next);
}
return pWndLast->hwndSelf;
retvalue = pWndLast->hwndSelf;
WIN_ReleaseWndPtr(pWndLast);
WIN_ReleaseWndPtr(pWnd);
END:
WIN_ReleaseWndPtr(pWndCtrl);
WIN_ReleaseWndPtr(pWndDlg);
return retvalue;
}
......
......@@ -892,6 +892,7 @@ static HRESULT WINAPI SysMouseAImpl_Acquire(LPDIRECTINPUTDEVICE2A iface)
/* This stores the current mouse handler.
FIXME : need to be fixed for native USER use */
WND *tempWnd = 0;
This->prev_handler = mouse_event;
/* Store (in a global variable) the current lock */
......
......@@ -34,13 +34,17 @@ void FOCUS_SwitchFocus( MESSAGEQUEUE *pMsgQ, HWND hFocusFrom, HWND hFocusTo )
#endif
if( !pFocusTo || hFocusTo != PERQDATA_GetFocusWnd( pMsgQ->pQData ) )
{
WIN_ReleaseWndPtr(pFocusTo);
return;
}
/* According to API docs, the WM_SETFOCUS message is sent AFTER the window
has received the keyboard focus. */
pFocusTo->pDriver->pSetFocus(pFocusTo);
WIN_ReleaseWndPtr(pFocusTo);
#if 0
SendMessageA( hFocusTo, WM_SETFOCUS, hFocusFrom, 0 );
#else
......@@ -154,6 +158,7 @@ CLEANUP:
if ( pCurMsgQ )
QUEUE_Unlock( pCurMsgQ );
WIN_ReleaseWndPtr(wndPtr);
return bRet ? hWndFocus : 0;
}
......
......@@ -335,6 +335,7 @@ HWND EVENT_Capture(HWND hwnd, INT16 ht)
WND* wndPtr = WIN_FindWndPtr( capturePrev );
if( wndPtr && (wndPtr->flags & WIN_ISWIN32) )
SendMessageA( capturePrev, WM_CAPTURECHANGED, 0L, hwnd);
WIN_ReleaseWndPtr(wndPtr);
}
}
......@@ -345,6 +346,7 @@ CLEANUP:
if ( pCurMsgQ )
QUEUE_Unlock( pCurMsgQ );
WIN_ReleaseWndPtr(wndPtr);
return capturePrev;
}
......@@ -598,6 +600,8 @@ static BOOL KBD_translate_accelerator(HWND hWnd,LPMSG msg,
iStat = (hMenu) ? GetMenuState(hMenu,
cmd, MF_BYCOMMAND) : -1 ;
WIN_ReleaseWndPtr(wndPtr);
if (iSysStat!=-1)
{
if (iSysStat & (MF_DISABLED|MF_GRAYED))
......
......@@ -349,6 +349,7 @@ DrawCaptionTempA (HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont,
DrawIconEx (hdc, pt.x, pt.y, hAppIcon, sysMetrics[SM_CXSMICON],
sysMetrics[SM_CYSMICON], 0, 0, DI_NORMAL);
WIN_ReleaseWndPtr(wndPtr);
}
rc.left += (rc.bottom - rc.top);
......@@ -554,7 +555,7 @@ static void NC_GetInsideRect( HWND hwnd, RECT *rect )
rect->right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
rect->bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
if ((wndPtr->dwStyle & WS_ICONIC) || (wndPtr->flags & WIN_MANAGED)) return;
if ((wndPtr->dwStyle & WS_ICONIC) || (wndPtr->flags & WIN_MANAGED)) goto END;
/* Remove frame from rectangle */
if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
......@@ -570,7 +571,8 @@ static void NC_GetInsideRect( HWND hwnd, RECT *rect )
if (wndPtr->dwStyle & WS_BORDER)
InflateRect( rect, -SYSMETRICS_CXBORDER, -SYSMETRICS_CYBORDER );
}
END:
WIN_ReleaseWndPtr(wndPtr);
return;
}
......@@ -592,7 +594,7 @@ NC_GetInsideRect95 (HWND hwnd, RECT *rect)
rect->right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
rect->bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
if ((wndPtr->dwStyle & WS_ICONIC) || (wndPtr->flags & WIN_MANAGED)) return;
if ((wndPtr->dwStyle & WS_ICONIC) || (wndPtr->flags & WIN_MANAGED)) goto END;
/* Remove frame from rectangle */
if (HAS_FIXEDFRAME (wndPtr->dwStyle, wndPtr->dwExStyle ))
......@@ -614,7 +616,8 @@ NC_GetInsideRect95 (HWND hwnd, RECT *rect)
if (wndPtr->dwExStyle & WS_EX_STATICEDGE)
InflateRect (rect, -SYSMETRICS_CXBORDER, -SYSMETRICS_CYBORDER);
}
END:
WIN_ReleaseWndPtr(wndPtr);
return;
}
......@@ -907,15 +910,18 @@ NC_DoNCHitTest95 (WND *wndPtr, POINT16 pt )
LONG
NC_HandleNCHitTest (HWND hwnd , POINT16 pt)
{
LONG retvalue;
WND *wndPtr = WIN_FindWndPtr (hwnd);
if (!wndPtr)
return HTERROR;
if (TWEAK_WineLook == WIN31_LOOK)
return NC_DoNCHitTest (wndPtr, pt);
retvalue = NC_DoNCHitTest (wndPtr, pt);
else
return NC_DoNCHitTest95 (wndPtr, pt);
retvalue = NC_DoNCHitTest95 (wndPtr, pt);
WIN_ReleaseWndPtr(wndPtr);
return retvalue;
}
......@@ -940,6 +946,7 @@ void NC_DrawSysButton( HWND hwnd, HDC hdc, BOOL down )
SelectObject( hdcMem, hbitmap );
DeleteDC( hdcMem );
}
WIN_ReleaseWndPtr(wndPtr);
}
......@@ -964,6 +971,8 @@ static void NC_DrawMaxButton( HWND hwnd, HDC16 hdc, BOOL down )
SRCCOPY );
DeleteDC( hdcMem );
}
WIN_ReleaseWndPtr(wndPtr);
}
......@@ -987,6 +996,7 @@ static void NC_DrawMinButton( HWND hwnd, HDC16 hdc, BOOL down )
SRCCOPY );
DeleteDC( hdcMem );
}
WIN_ReleaseWndPtr(wndPtr);
}
......@@ -1030,8 +1040,10 @@ NC_DrawSysButton95 (HWND hwnd, HDC hdc, BOOL down)
sysMetrics[SM_CYSMICON],
0, 0, DI_NORMAL);
WIN_ReleaseWndPtr(wndPtr);
return (hIcon != 0);
}
WIN_ReleaseWndPtr(wndPtr);
return FALSE;
}
......@@ -1075,6 +1087,7 @@ void NC_DrawCloseButton95 (HWND hwnd, HDC hdc, BOOL down)
SelectObject (hdcMem, hOldBmp);
DeleteDC (hdcMem);
}
WIN_ReleaseWndPtr(wndPtr);
}
/******************************************************************************
......@@ -1125,6 +1138,7 @@ static void NC_DrawMaxButton95(HWND hwnd,HDC16 hdc,BOOL down )
SelectObject (hdcMem, hOldBmp);
DeleteDC( hdcMem );
}
WIN_ReleaseWndPtr(wndPtr);
}
/******************************************************************************
......@@ -1178,6 +1192,7 @@ static void NC_DrawMinButton95(HWND hwnd,HDC16 hdc,BOOL down )
SelectObject (hdcMem, hOldBmp);
DeleteDC( hdcMem );
}
WIN_ReleaseWndPtr(wndPtr);
}
/***********************************************************************
......@@ -1357,12 +1372,19 @@ static void NC_DrawCaption( HDC hdc, RECT *rect, HWND hwnd,
WND * wndPtr = WIN_FindWndPtr( hwnd );
char buffer[256];
if (wndPtr->flags & WIN_MANAGED) return;
if (wndPtr->flags & WIN_MANAGED)
{
WIN_ReleaseWndPtr(wndPtr);
return;
}
if (!hbitmapClose)
{
if (!(hbitmapClose = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_CLOSE) )))
{
WIN_ReleaseWndPtr(wndPtr);
return;
}
hbitmapCloseD = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_CLOSED) );
hbitmapMinimize = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_REDUCE) );
hbitmapMinimizeD = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_REDUCED) );
......@@ -1382,7 +1404,7 @@ static void NC_DrawCaption( HDC hdc, RECT *rect, HWND hwnd,
r.right--;
SelectObject( hdc, hbrushOld );
}
WIN_ReleaseWndPtr(wndPtr);
MoveTo16( hdc, r.left, r.bottom );
LineTo( hdc, r.right, r.bottom );
......@@ -1455,7 +1477,12 @@ static void NC_DrawCaption95(
char buffer[256];
HPEN hPrevPen;
if (wndPtr->flags & WIN_MANAGED) return;
if (wndPtr->flags & WIN_MANAGED)
{
WIN_ReleaseWndPtr(wndPtr);
return;
}
WIN_ReleaseWndPtr(wndPtr);
hPrevPen = SelectObject( hdc, GetSysColorPen(COLOR_3DFACE) );
MoveToEx( hdc, r.left, r.bottom - 1, NULL );
......@@ -1755,6 +1782,7 @@ LONG NC_HandleNCPaint( HWND hwnd , HRGN clip)
else
NC_DoNCPaint95( wndPtr, clip, FALSE );
}
WIN_ReleaseWndPtr(wndPtr);
return 0;
}
......@@ -1810,13 +1838,17 @@ LONG NC_HandleSetCursor( HWND hwnd, WPARAM16 wParam, LPARAM lParam )
case HTCLIENT:
{
WND *wndPtr;
BOOL retvalue;
if (!(wndPtr = WIN_FindWndPtr( hwnd ))) break;
if (wndPtr->class->hCursor)
{
SetCursor16( wndPtr->class->hCursor );
return TRUE;
retvalue = TRUE;
}
else return FALSE;
else retvalue = FALSE;
WIN_ReleaseWndPtr(wndPtr);
return retvalue;
}
case HTLEFT:
......@@ -1981,18 +2013,18 @@ static void NC_DoSizeMove( HWND hwnd, WORD wParam )
capturePoint = pt = *(POINT16*)&dwPoint;
if (IsZoomed(hwnd) || !IsWindowVisible(hwnd) ||
(wndPtr->flags & WIN_MANAGED)) return;
(wndPtr->flags & WIN_MANAGED)) goto END;
if ((wParam & 0xfff0) == SC_MOVE)
{
if (!(wndPtr->dwStyle & WS_CAPTION)) return;
if (!(wndPtr->dwStyle & WS_CAPTION)) goto END;
if (!hittest)
hittest = NC_StartSizeMove( wndPtr, wParam, &capturePoint );
if (!hittest) return;
if (!hittest) goto END;
}
else /* SC_SIZE */
{
if (!thickframe) return;
if (!thickframe) goto END;
if ( hittest && hittest != HTSYSMENU ) hittest += 2;
else
{
......@@ -2001,7 +2033,7 @@ static void NC_DoSizeMove( HWND hwnd, WORD wParam )
if (!hittest)
{
ReleaseCapture();
return;
goto END;
}
}
}
......@@ -2193,6 +2225,9 @@ static void NC_DoSizeMove( HWND hwnd, WORD wParam )
}
else WINPOS_ShowIconTitle( wndPtr, TRUE );
}
END:
WIN_ReleaseWndPtr(wndPtr);
}
......@@ -2295,16 +2330,16 @@ static void NC_TrackScrollBar( HWND hwnd, WPARAM wParam, POINT pt )
if ((wParam & 0xfff0) == SC_HSCROLL)
{
if ((wParam & 0x0f) != HTHSCROLL) return;
if ((wParam & 0x0f) != HTHSCROLL) goto END;
scrollbar = SB_HORZ;
}
else /* SC_VSCROLL */
{
if ((wParam & 0x0f) != HTVSCROLL) return;
if ((wParam & 0x0f) != HTVSCROLL) goto END;
scrollbar = SB_VERT;
}
if (!(msg = SEGPTR_NEW(MSG16))) return;
if (!(msg = SEGPTR_NEW(MSG16))) goto END;
pt.x -= wndPtr->rectWindow.left;
pt.y -= wndPtr->rectWindow.top;
SetCapture( hwnd );
......@@ -2336,6 +2371,8 @@ static void NC_TrackScrollBar( HWND hwnd, WPARAM wParam, POINT pt )
}
} while (msg->message != WM_LBUTTONUP);
SEGPTR_FREE(msg);
END:
WIN_ReleaseWndPtr(wndPtr);
}
/***********************************************************************
......@@ -2532,5 +2569,6 @@ LONG NC_HandleSysCommand( HWND hwnd, WPARAM16 wParam, POINT16 pt )
FIXME (nonclient, "unimplemented!\n");
break;
}
WIN_ReleaseWndPtr(wndPtr);
return 0;
}
......@@ -35,8 +35,10 @@ void WIN_UpdateNCArea(WND* wnd, BOOL bUpdate)
if(wnd == WIN_GetDesktop())
{
wnd->flags &= ~WIN_NEEDS_NCPAINT;
WIN_ReleaseDesktop();
return;
}
WIN_ReleaseDesktop();
if( wnd->hrgnUpdate > 1 )
{
......@@ -136,6 +138,7 @@ HDC16 WINAPI BeginPaint16( HWND16 hwnd, LPPAINTSTRUCT16 lps )
if (!lps->hdc)
{
WARN(win, "GetDCEx() failed in BeginPaint(), hwnd=%04x\n", hwnd);
WIN_ReleaseWndPtr(wndPtr);
return 0;
}
......@@ -153,6 +156,7 @@ TRACE(win,"box = (%i,%i - %i,%i)\n", lps->rcPaint.left, lps->rcPaint.top,
}
else lps->fErase = TRUE;
WIN_ReleaseWndPtr(wndPtr);
return lps->hdc;
}
......@@ -248,17 +252,23 @@ void WINAPI PaintRect16( HWND16 hwndParent, HWND16 hwnd, HDC16 hdc,
HBRUSH16 WINAPI GetControlBrush16( HWND16 hwnd, HDC16 hdc, UINT16 ctlType )
{
WND* wndPtr = WIN_FindWndPtr( hwnd );
HBRUSH16 retvalue;
if((ctlType <= CTLCOLOR_MAX) && wndPtr )
{
WND* parent;
if( wndPtr->dwStyle & WS_POPUP ) parent = wndPtr->owner;
else parent = wndPtr->parent;
if( wndPtr->dwStyle & WS_POPUP ) parent = WIN_LockWndPtr(wndPtr->owner);
else parent = WIN_LockWndPtr(wndPtr->parent);
if( !parent ) parent = wndPtr;
return (HBRUSH16)PAINT_GetControlBrush( parent->hwndSelf, hwnd, hdc, ctlType );
retvalue = (HBRUSH16)PAINT_GetControlBrush( parent->hwndSelf, hwnd, hdc, ctlType );
WIN_ReleaseWndPtr(parent);
goto END;
}
retvalue = (HBRUSH16)0;
END:
WIN_ReleaseWndPtr(wndPtr);
return retvalue;
}
return (HBRUSH16)0;
}
/***********************************************************************
......@@ -290,7 +300,10 @@ BOOL PAINT_RedrawWindow( HWND hwnd, const RECT *rectUpdate,
if (!hwnd) hwnd = GetDesktopWindow();
if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
if (!WIN_IsWindowDrawable( wndPtr, !(flags & RDW_FRAME) ) )
{
WIN_ReleaseWndPtr(wndPtr);
return TRUE; /* No redraw needed */
}
bIcon = (wndPtr->dwStyle & WS_MINIMIZE && wndPtr->class->hIcon);
if (rectUpdate)
......@@ -440,13 +453,18 @@ BOOL PAINT_RedrawWindow( HWND hwnd, const RECT *rectUpdate,
{
if ( hrgnUpdate || rectUpdate )
{
if (!(hrgn = CreateRectRgn( 0, 0, 0, 0 ))) return TRUE;
if (!(hrgn = CreateRectRgn( 0, 0, 0, 0 )))
{
WIN_ReleaseWndPtr(wndPtr);
return TRUE;
}
if( !hrgnUpdate )
{
control |= (RDW_C_DELETEHRGN | RDW_C_USEHRGN);
if( !(hrgnUpdate = CreateRectRgnIndirect( rectUpdate )) )
{
DeleteObject( hrgn );
WIN_ReleaseWndPtr(wndPtr);
return TRUE;
}
}
......@@ -454,7 +472,7 @@ BOOL PAINT_RedrawWindow( HWND hwnd, const RECT *rectUpdate,
{
for (ppWnd = list; *ppWnd; ppWnd++)
{
wndPtr = *ppWnd;
WIN_UpdateWndPtr(&wndPtr,*ppWnd);
if (!IsWindow(wndPtr->hwndSelf)) continue;
if (wndPtr->dwStyle & WS_VISIBLE)
{
......@@ -470,7 +488,7 @@ BOOL PAINT_RedrawWindow( HWND hwnd, const RECT *rectUpdate,
}
}
}
HeapFree( SystemHeap, 0, list );
WIN_ReleaseWinArray(list);
}
DeleteObject( hrgn );
if (control & RDW_C_DELETEHRGN) DeleteObject( hrgnUpdate );
......@@ -481,15 +499,16 @@ BOOL PAINT_RedrawWindow( HWND hwnd, const RECT *rectUpdate,
{
for (ppWnd = list; *ppWnd; ppWnd++)
{
wndPtr = *ppWnd;
WIN_UpdateWndPtr(&wndPtr,*ppWnd);
if (IsWindow( wndPtr->hwndSelf ))
PAINT_RedrawWindow( wndPtr->hwndSelf, NULL, 0, flags, 0 );
}
HeapFree( SystemHeap, 0, list );
WIN_ReleaseWinArray(list);
}
}
}
WIN_ReleaseWndPtr(wndPtr);
return TRUE;
}
......@@ -632,6 +651,7 @@ BOOL16 WINAPI GetUpdateRect16( HWND16 hwnd, LPRECT16 rect, BOOL16 erase )
*/
BOOL WINAPI GetUpdateRect( HWND hwnd, LPRECT rect, BOOL erase )
{
BOOL retvalue;
WND * wndPtr = WIN_FindWndPtr( hwnd );
if (!wndPtr) return FALSE;
......@@ -640,7 +660,11 @@ BOOL WINAPI GetUpdateRect( HWND hwnd, LPRECT rect, BOOL erase )
if (wndPtr->hrgnUpdate > 1)
{
HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
if (GetUpdateRgn( hwnd, hrgn, erase ) == ERROR) return FALSE;
if (GetUpdateRgn( hwnd, hrgn, erase ) == ERROR)
{
retvalue = FALSE;
goto END;
}
GetRgnBox( hrgn, rect );
DeleteObject( hrgn );
if (wndPtr->class->style & CS_OWNDC)
......@@ -653,7 +677,10 @@ BOOL WINAPI GetUpdateRect( HWND hwnd, LPRECT rect, BOOL erase )
}
else SetRectEmpty( rect );
}
return (wndPtr->hrgnUpdate > 1);
retvalue = (wndPtr->hrgnUpdate > 1);
END:
WIN_ReleaseWndPtr(wndPtr);
return retvalue;
}
......@@ -678,10 +705,13 @@ INT WINAPI GetUpdateRgn( HWND hwnd, HRGN hrgn, BOOL erase )
if (wndPtr->hrgnUpdate <= 1)
{
SetRectRgn( hrgn, 0, 0, 0, 0 );
return NULLREGION;
retval = NULLREGION;
goto END;
}
retval = CombineRgn( hrgn, wndPtr->hrgnUpdate, 0, RGN_COPY );
if (erase) RedrawWindow( hwnd, NULL, 0, RDW_ERASENOW | RDW_NOCHILDREN );
END:
WIN_ReleaseWndPtr(wndPtr);
return retval;
}
......@@ -719,8 +749,10 @@ INT WINAPI ExcludeUpdateRgn( HDC hdc, HWND hwnd )
ret = DCE_ExcludeRgn( hdc, wndPtr, hrgn );
DeleteObject( hrgn );
WIN_ReleaseWndPtr(wndPtr);
return ret;
}
WIN_ReleaseWndPtr(wndPtr);
return GetClipBox( hdc, &rect );
}
......
......@@ -35,9 +35,9 @@ static PROPERTY *PROP_FindProp( HWND hwnd, LPCSTR str )
{
if (HIWORD(prop->string))
{
if (!lstrcmpiA( prop->string, str )) return prop;
if (!lstrcmpiA( prop->string, str )) goto END;
}
else if (LOWORD(prop->string) == atom) return prop;
else if (LOWORD(prop->string) == atom) goto END;
}
}
else /* atom */
......@@ -47,12 +47,15 @@ static PROPERTY *PROP_FindProp( HWND hwnd, LPCSTR str )
{
if (HIWORD(prop->string))
{
if (GlobalFindAtomA( prop->string ) == atom) return prop;
if (GlobalFindAtomA( prop->string ) == atom) goto END;
}
else if (LOWORD(prop->string) == atom) return prop;
else if (LOWORD(prop->string) == atom) goto END;
}
}
return NULL;
prop = NULL;
END:
WIN_ReleaseWndPtr(pWnd);
return prop;
}
......@@ -126,14 +129,21 @@ BOOL WINAPI SetPropA( HWND hwnd, LPCSTR str, HANDLE handle )
/* We need to create it */
WND *pWnd = WIN_FindWndPtr( hwnd );
if (!pWnd) return FALSE;
if (!(prop = HeapAlloc( SystemHeap, 0, sizeof(*prop) ))) return FALSE;
if (!(prop = HeapAlloc( SystemHeap, 0, sizeof(*prop) )))
{
WIN_ReleaseWndPtr(pWnd);
return FALSE;
}
if (!(prop->string = SEGPTR_STRDUP(str)))
{
HeapFree( SystemHeap, 0, prop );
WIN_ReleaseWndPtr(pWnd);
return FALSE;
}
prop->next = pWnd->pProp;
pWnd->pProp = prop;
WIN_ReleaseWndPtr(pWnd);
}
prop->handle = handle;
return TRUE;
......@@ -207,6 +217,7 @@ HANDLE WINAPI RemovePropA( HWND hwnd, LPCSTR str )
else if (LOWORD((*pprop)->string) == atom) break;
}
}
WIN_ReleaseWndPtr(pWnd);
if (!*pprop) return 0;
prop = *pprop;
handle = prop->handle;
......@@ -275,6 +286,7 @@ INT16 WINAPI EnumProps16( HWND16 hwnd, PROPENUMPROC16 func )
ret = func( hwnd, SEGPTR_GET(prop->string), prop->handle );
if (!ret) break;
}
WIN_ReleaseWndPtr(pWnd);
return ret;
}
......@@ -320,6 +332,7 @@ INT WINAPI EnumPropsExA(HWND hwnd, PROPENUMPROCEXA func, LPARAM lParam)
ret = func( hwnd, prop->string, prop->handle, lParam );
if (!ret) break;
}
WIN_ReleaseWndPtr(pWnd);
return ret;
}
......@@ -355,5 +368,6 @@ INT WINAPI EnumPropsExW(HWND hwnd, PROPENUMPROCEXW func, LPARAM lParam)
prop->handle, lParam );
if (!ret) break;
}
WIN_ReleaseWndPtr(pWnd);
return ret;
}
......@@ -924,6 +924,7 @@ void QUEUE_ReceiveMessage( MESSAGEQUEUE *queue )
smsg->lParam );
queue->GetMessageExtraInfoVal = extraInfo; /* Restore extra info */
WIN_ReleaseWndPtr(wndPtr);
TRACE(sendmsg,"result = %08x\n", (unsigned)result );
}
else WARN(sendmsg, "\trcm: bad hWnd\n");
......@@ -1090,13 +1091,17 @@ static void QUEUE_WakeSomeone( UINT message )
if( (wndPtr = WIN_FindWndPtr( hwnd )) )
{
hQueue = wndPtr->hmemTaskQ;
WIN_ReleaseWndPtr(wndPtr);
}
}
if( (hwnd = GetSysModalWindow16()) )
{
if( (wndPtr = WIN_FindWndPtr( hwnd )) )
{
hQueue = wndPtr->hmemTaskQ;
WIN_ReleaseWndPtr(wndPtr);
}
}
if (hQueue)
......@@ -1309,10 +1314,13 @@ void WINAPI PostQuitMessage( INT exitCode )
*/
HTASK16 WINAPI GetWindowTask16( HWND16 hwnd )
{
HTASK16 retvalue;
WND *wndPtr = WIN_FindWndPtr( hwnd );
if (!wndPtr) return 0;
return QUEUE_GetQueueTask( wndPtr->hmemTaskQ );
retvalue = QUEUE_GetQueueTask( wndPtr->hmemTaskQ );
WIN_ReleaseWndPtr(wndPtr);
return retvalue;
}
/***********************************************************************
......@@ -1321,12 +1329,14 @@ HTASK16 WINAPI GetWindowTask16( HWND16 hwnd )
DWORD WINAPI GetWindowThreadProcessId( HWND hwnd, LPDWORD process )
{
HTASK16 htask;
DWORD retvalue;
TDB *tdb;
WND *wndPtr = WIN_FindWndPtr( hwnd );
if (!wndPtr) return 0;
htask=QUEUE_GetQueueTask( wndPtr->hmemTaskQ );
WIN_ReleaseWndPtr(wndPtr);
tdb = (TDB*)GlobalLock16(htask);
if (!tdb || !tdb->thdb) return 0;
if (process) *process = (DWORD)tdb->thdb->process->server_pid;
......
......@@ -236,7 +236,11 @@ INT WINAPI ScrollWindowEx( HWND hwnd, INT dx, INT dy,
RECT rc, cliprc;
WND* wnd = WIN_FindWndPtr( hwnd );
if( !wnd || !WIN_IsWindowDrawable( wnd, TRUE )) return ERROR;
if( !wnd || !WIN_IsWindowDrawable( wnd, TRUE ))
{
retVal = ERROR;
goto END;
}
GetClientRect(hwnd, &rc);
if (rect) IntersectRect(&rc, &rc, rect);
......@@ -307,7 +311,7 @@ rc.left, rc.top, rc.right, rc.bottom, (UINT16)flags );
{
RECT r;
WND* w;
for( w = wnd->child; w; w = w->next )
for( w =WIN_LockWndPtr(wnd->child); w; WIN_UpdateWndPtr(&w, w->next))
{
CONV_RECT16TO32( &w->rectWindow, &r );
if( IntersectRect(&r, &r, &rc) )
......@@ -332,5 +336,7 @@ rc.left, rc.top, rc.right, rc.bottom, (UINT16)flags );
DeleteObject( hrgnClip );
DeleteObject( hrgnTemp );
}
END:
WIN_ReleaseWndPtr(wnd);
return retVal;
}
......@@ -391,9 +391,13 @@ WINDOWPROCTYPE WINPROC_GetProcType( HWINDOWPROC proc )
* Return TRUE if the lparam is a string
*/
BOOL WINPROC_TestCBForStr ( HWND hwnd )
{ WND * wnd = WIN_FindWndPtr(hwnd);
return ( !(LOWORD(wnd->dwStyle) & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) ||
{
BOOL retvalue;
WND * wnd = WIN_FindWndPtr(hwnd);
retvalue = ( !(LOWORD(wnd->dwStyle) & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) ||
(LOWORD(wnd->dwStyle) & CBS_HASSTRINGS) );
WIN_ReleaseWndPtr(wnd);
return retvalue;
}
/**********************************************************************
* WINPROC_TestLBForStr
......@@ -401,9 +405,14 @@ BOOL WINPROC_TestCBForStr ( HWND hwnd )
* Return TRUE if the lparam is a string
*/
BOOL WINPROC_TestLBForStr ( HWND hwnd )
{ WND * wnd = WIN_FindWndPtr(hwnd);
return ( !(LOWORD(wnd->dwStyle) & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) ||
{
BOOL retvalue;
WND * wnd = WIN_FindWndPtr(hwnd);
retvalue = ( !(LOWORD(wnd->dwStyle) & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) ||
(LOWORD(wnd->dwStyle) & LBS_HASSTRINGS) );
WIN_ReleaseWndPtr(wnd);
return retvalue;
}
/**********************************************************************
* WINPROC_MapMsg32ATo32W
......@@ -1681,8 +1690,10 @@ INT WINPROC_MapMsg32ATo16( HWND hwnd, UINT msg32, WPARAM wParam32,
*plparam = MAKELPARAM( HIWORD(wParam32), (HMENU16)*plparam );
return 0;
case WM_MDIACTIVATE:
if( WIDGETS_IsControl(WIN_FindWndPtr(hwnd), BIC32_MDICLIENT) )
{
WND *tempWnd = WIN_FindWndPtr(hwnd);
if( WIDGETS_IsControl(tempWnd, BIC32_MDICLIENT) )
{
*pwparam16 = (HWND)wParam32;
*plparam = 0;
}
......@@ -1692,6 +1703,8 @@ INT WINPROC_MapMsg32ATo16( HWND hwnd, UINT msg32, WPARAM wParam32,
*plparam = MAKELPARAM( (HWND16)LOWORD(*plparam),
(HWND16)LOWORD(wParam32) );
}
WIN_ReleaseWndPtr(tempWnd);
}
return 0;
case WM_NCCALCSIZE:
{
......
......@@ -208,9 +208,8 @@ void X11DRV_CLIPBOARD_SetClipboardData(UINT wFormat)
if( !selectionAcquired &&
(wFormat == CF_TEXT || wFormat == CF_OEMTEXT) )
{
owner = X11DRV_WND_FindXWindow(
WIN_FindWndPtr( hWndClipWindow ? hWndClipWindow : AnyPopup() )
);
WND *tmpWnd = WIN_FindWndPtr( hWndClipWindow ? hWndClipWindow : AnyPopup() );
owner = X11DRV_WND_FindXWindow(tmpWnd );
TSXSetSelectionOwner(display,XA_PRIMARY, owner, CurrentTime);
if( TSXGetSelectionOwner(display,XA_PRIMARY) == owner )
......@@ -221,6 +220,7 @@ void X11DRV_CLIPBOARD_SetClipboardData(UINT wFormat)
TRACE(clipboard,"Grabbed X selection, owner=(%08x)\n",
(unsigned) owner);
}
WIN_ReleaseWndPtr(tmpWnd);
}
}
......@@ -230,6 +230,7 @@ void X11DRV_CLIPBOARD_SetClipboardData(UINT wFormat)
BOOL X11DRV_CLIPBOARD_RequestSelection()
{
HWND hWnd = (hWndClipWindow) ? hWndClipWindow : GetActiveWindow();
WND *tmpWnd = WIN_FindWndPtr(hWnd);
if( selectionAcquired )
return TRUE;
......@@ -244,8 +245,10 @@ BOOL X11DRV_CLIPBOARD_RequestSelection()
TSXConvertSelection(display, XA_PRIMARY, XA_STRING,
TSXInternAtom(display, "PRIMARY_TEXT", False),
X11DRV_WND_FindXWindow( WIN_FindWndPtr( hWnd ) ),
X11DRV_WND_FindXWindow(tmpWnd ),
CurrentTime);
WIN_ReleaseWndPtr(tmpWnd);
/* wait until SelectionNotify is processed
*
......
......@@ -1205,6 +1205,8 @@ static void EVENT_DropFromOffiX( WND *pWnd, XClientMessageEvent *event )
if( p_data ) TSXFree(p_data);
} /* WS_EX_ACCEPTFILES */
WIN_ReleaseWndPtr(pDropWnd);
}
/**********************************************************************
......@@ -1349,6 +1351,7 @@ static void EVENT_DropURLs( WND *pWnd, XClientMessageEvent *event )
(WPARAM16)hDrop.h16, 0L );
}
}
WIN_ReleaseWndPtr(pDropWnd);
}
if( p_data ) TSXFree(p_data);
}
......@@ -1413,9 +1416,11 @@ void EVENT_EnterNotify( WND *pWnd, XCrossingEvent *event )
void EVENT_MapNotify( HWND hWnd, XMapEvent *event )
{
HWND hwndFocus = GetFocus();
WND *tmpWnd = WIN_FindWndPtr(hwndFocus);
if (hwndFocus && IsChild( hWnd, hwndFocus ))
X11DRV_WND_SetFocus( WIN_FindWndPtr( hwndFocus ) );
X11DRV_WND_SetFocus(tmpWnd );
WIN_ReleaseWndPtr(tmpWnd);
return;
}
......
......@@ -154,12 +154,15 @@ static BOOL X11DRV_MOUSE_DoSetCursor( CURSORICONINFO *ptr )
HWND hwnd = GetWindow( GetDesktopWindow(), GW_CHILD );
while(hwnd)
{
Window win = X11DRV_WND_FindXWindow( WIN_FindWndPtr( hwnd ) );
WND *tmpWnd = WIN_FindWndPtr(hwnd);
Window win = X11DRV_WND_FindXWindow(tmpWnd );
if (win && win!=DefaultRootWindow(display))
XDefineCursor( display, win, cursor );
hwnd = GetWindow( hwnd, GW_HWNDNEXT );
WIN_ReleaseWndPtr(tmpWnd);
}
}
WIN_ReleaseDesktop();
return TRUE;
}
......
......@@ -234,8 +234,10 @@ BOOL X11DRV_WND_CreateWindow(WND *wndPtr, CLASS *classPtr, CREATESTRUCTA *cs, BO
if (cs->hwndParent) /* Get window owner */
{
Window win = X11DRV_WND_FindXWindow( WIN_FindWndPtr( cs->hwndParent ) );
WND *tmpWnd = WIN_FindWndPtr(cs->hwndParent);
Window win = X11DRV_WND_FindXWindow( tmpWnd );
if (win) TSXSetTransientForHint( display, X11DRV_WND_GetXWindow(wndPtr), win );
WIN_ReleaseWndPtr(tmpWnd);
}
X11DRV_WND_RegisterWindow( wndPtr );
}
......@@ -264,7 +266,9 @@ BOOL X11DRV_WND_DestroyWindow(WND *wndPtr)
*/
WND *X11DRV_WND_SetParent(WND *wndPtr, WND *pWndParent)
{
if( wndPtr && pWndParent && (wndPtr != WIN_GetDesktop()) )
WND *pDesktop = WIN_GetDesktop();
if( wndPtr && pWndParent && (wndPtr != pDesktop) )
{
WND* pWndPrev = wndPtr->parent;
......@@ -284,7 +288,7 @@ WND *X11DRV_WND_SetParent(WND *wndPtr, WND *pWndParent)
/* Create an X counterpart for reparented top-level windows
* when not in the desktop mode. */
if( pWndParent == WIN_GetDesktop () )
if( pWndParent == pDesktop )
{
wndPtr->dwStyle &= ~WS_CHILD;
wndPtr->wIDmenu = 0;
......@@ -325,8 +329,10 @@ WND *X11DRV_WND_SetParent(WND *wndPtr, WND *pWndParent)
}
WIN_LinkWindow(wndPtr->hwndSelf, HWND_TOP);
}
WIN_ReleaseDesktop();
return pWndPrev;
} /* failure */
WIN_ReleaseDesktop();
return 0;
}
......@@ -339,7 +345,7 @@ WND *X11DRV_WND_SetParent(WND *wndPtr, WND *pWndParent)
void X11DRV_WND_ForceWindowRaise(WND *wndPtr)
{
XWindowChanges winChanges;
WND *wndPrev;
WND *wndPrev,*pDesktop = WIN_GetDesktop();
if( !wndPtr || !X11DRV_WND_GetXWindow(wndPtr) || (wndPtr->flags & WIN_MANAGED) )
return;
......@@ -354,11 +360,12 @@ void X11DRV_WND_ForceWindowRaise(WND *wndPtr)
if (X11DRV_WND_GetXWindow(wndPtr))
TSXReconfigureWMWindow( display, X11DRV_WND_GetXWindow(wndPtr), 0,
CWStackMode, &winChanges );
wndPrev = WIN_GetDesktop()->child;
wndPrev = pDesktop->child;
if (wndPrev == wndPtr) break;
while (wndPrev && (wndPrev->next != wndPtr)) wndPrev = wndPrev->next;
wndPtr = wndPrev;
}
WIN_ReleaseDesktop();
}
/***********************************************************************
......@@ -460,6 +467,8 @@ void X11DRV_WND_SetWindowPos(WND *wndPtr, const WINDOWPOS *winpos, BOOL bSMC_SET
TSXRestackWindows(display, stack, 2);
changeMask &= ~CWStackMode;
WIN_ReleaseWndPtr(insertPtr);
}
}
if (changeMask)
......@@ -472,6 +481,7 @@ void X11DRV_WND_SetWindowPos(WND *wndPtr, const WINDOWPOS *winpos, BOOL bSMC_SET
{
if(X11DRV_WND_GetXWindow(wndPtr)) TSXMapWindow( display, X11DRV_WND_GetXWindow(wndPtr) );
}
WIN_ReleaseWndPtr(winposPtr);
}
/*****************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment