Cleaned up assumptions about WS_CHILD flag so that we can allow it to
be changed in SetWindowLong.
diff --git a/windows/dce.c b/windows/dce.c
index 15ce262..34b7451 100644
--- a/windows/dce.c
+++ b/windows/dce.c
@@ -560,7 +560,7 @@
* WS_CLIPSIBLINGS style
*/
- while (wndPtr->dwStyle & WS_CHILD)
+ while (wndPtr->parent)
{
WIN_UpdateWndPtr(&wndPtr,wndPtr->parent);
xoffset -= wndPtr->rectClient.left;
diff --git a/windows/dialog.c b/windows/dialog.c
index d489836..f143731 100644
--- a/windows/dialog.c
+++ b/windows/dialog.c
@@ -1994,7 +1994,7 @@
goto END;
}
/* Make sure hwndCtrl is a top-level child */
- while ((pWndCtrl->dwStyle & WS_CHILD) && (pWndCtrl->parent != pWndDlg))
+ while (pWndCtrl->parent && (pWndCtrl->parent != pWndDlg))
WIN_UpdateWndPtr(&pWndCtrl,pWndCtrl->parent);
if (pWndCtrl->parent != pWndDlg)
{
diff --git a/windows/nonclient.c b/windows/nonclient.c
index f61d82e..163411b 100644
--- a/windows/nonclient.c
+++ b/windows/nonclient.c
@@ -2101,7 +2101,7 @@
if (GetCapture() != hwnd) SetCapture( hwnd );
- if (wndPtr->dwStyle & WS_CHILD)
+ if (wndPtr->parent && (wndPtr->parent->hwndSelf != GetDesktopWindow()))
{
/* Retrieve a default cache DC (without using the window style) */
hdc = GetDCEx( wndPtr->parent->hwndSelf, 0, DCX_CACHE );
@@ -2235,7 +2235,7 @@
if(!DragFullWindows)
NC_DrawMovingFrame( hdc, &sizingRect, thickframe );
- if (wndPtr->dwStyle & WS_CHILD)
+ if (wndPtr->parent && (wndPtr->parent->hwndSelf != GetDesktopWindow()))
ReleaseDC( wndPtr->parent->hwndSelf, hdc );
else
ReleaseDC( 0, hdc );
@@ -2693,7 +2693,7 @@
TRACE("Handling WM_SYSCOMMAND %x %ld,%ld\n", wParam, pt.x, pt.y );
- if ((wndPtr->dwStyle & WS_CHILD) && (uCommand != SC_KEYMENU))
+ if (wndPtr->parent && (uCommand != SC_KEYMENU))
ScreenToClient( wndPtr->parent->hwndSelf, &pt );
switch (uCommand)
diff --git a/windows/win.c b/windows/win.c
index 9ba000e..e96504b 100644
--- a/windows/win.c
+++ b/windows/win.c
@@ -1329,11 +1329,11 @@
{
if (h == hwnd)
{
- SetFocus(GetWindowLongA(hwnd,GWL_HWNDPARENT));
+ SetFocus(GetParent(h));
bFocusSet = TRUE;
break;
}
- h = GetWindowLongA(h,GWL_HWNDPARENT);
+ h = GetParent(h);
}
/* If the focus is on the window we will destroy and it has no parent,
* set the focus to 0.
@@ -2031,9 +2031,7 @@
goto end;
case GWL_STYLE:
style.styleOld = wndPtr->dwStyle;
- newval &= ~(WS_CHILD); /* this bit can't be changed this way */
- style.styleNew = newval | (style.styleOld & (WS_CHILD));
-
+ style.styleNew = newval;
if (wndPtr->flags & WIN_ISWIN32)
SendMessageA(hwnd,WM_STYLECHANGING,GWL_STYLE,(LPARAM)&style);
wndPtr->dwStyle = style.styleNew;
@@ -2454,9 +2452,10 @@
BOOL WINAPI IsChild( HWND parent, HWND child )
{
WND * wndPtr = WIN_FindWndPtr( child );
- while (wndPtr && (wndPtr->dwStyle & WS_CHILD))
+ while (wndPtr && wndPtr->parent)
{
WIN_UpdateWndPtr(&wndPtr,wndPtr->parent);
+ if (wndPtr->hwndSelf == GetDesktopWindow()) break;
if (wndPtr->hwndSelf == parent)
{
WIN_ReleaseWndPtr(wndPtr);
@@ -2484,7 +2483,7 @@
{
BOOL retval;
WND *wndPtr = WIN_FindWndPtr( hwnd );
- while (wndPtr && (wndPtr->dwStyle & WS_CHILD))
+ while (wndPtr && wndPtr->parent)
{
if (!(wndPtr->dwStyle & WS_VISIBLE))
{
@@ -2496,7 +2495,6 @@
retval = (wndPtr && (wndPtr->dwStyle & WS_VISIBLE));
WIN_ReleaseWndPtr(wndPtr);
return retval;
-
}
@@ -3159,7 +3157,7 @@
if( !(ptrQueryWnd->dwStyle & WS_MINIMIZE) )
{
tempRect = ptrQueryWnd->rectClient;
- if(ptrQueryWnd->dwStyle & WS_CHILD)
+ if(ptrQueryWnd->parent)
MapWindowPoints( ptrQueryWnd->parent->hwndSelf, 0,
(LPPOINT)&tempRect, 2 );
diff --git a/windows/winpos.c b/windows/winpos.c
index 192a922..09cb948 100644
--- a/windows/winpos.c
+++ b/windows/winpos.c
@@ -246,7 +246,7 @@
if (!wndPtr) return;
CONV_RECT32TO16( &wndPtr->rectWindow, rect );
- if (wndPtr->dwStyle & WS_CHILD)
+ if (wndPtr->parent)
MapWindowPoints16( wndPtr->parent->hwndSelf, 0, (POINT16 *)rect, 2 );
WIN_ReleaseWndPtr(wndPtr);
}
@@ -261,7 +261,7 @@
if (!wndPtr) return FALSE;
*rect = wndPtr->rectWindow;
- if (wndPtr->dwStyle & WS_CHILD)
+ if (wndPtr->parent)
MapWindowPoints( wndPtr->parent->hwndSelf, 0, (POINT *)rect, 2 );
WIN_ReleaseWndPtr(wndPtr);
return TRUE;
diff --git a/windows/x11drv/wnd.c b/windows/x11drv/wnd.c
index fbed353..524ac46 100644
--- a/windows/x11drv/wnd.c
+++ b/windows/x11drv/wnd.c
@@ -851,7 +851,8 @@
void X11DRV_WND_PreSizeMove(WND *wndPtr)
{
/* Grab the server only when moving top-level windows without desktop */
- if (!(wndPtr->dwStyle & WS_CHILD) && (X11DRV_GetXRootWindow() == DefaultRootWindow(display)))
+ if ((X11DRV_GetXRootWindow() == DefaultRootWindow(display)) &&
+ (wndPtr->parent->hwndSelf == GetDesktopWindow()))
TSXGrabServer( display );
}
@@ -860,8 +861,8 @@
*/
void X11DRV_WND_PostSizeMove(WND *wndPtr)
{
- if (!(wndPtr->dwStyle & WS_CHILD) &&
- (X11DRV_GetXRootWindow() == DefaultRootWindow(display)))
+ if ((X11DRV_GetXRootWindow() == DefaultRootWindow(display)) &&
+ (wndPtr->parent->hwndSelf == GetDesktopWindow()))
TSXUngrabServer( display );
}