Index: win32ss/user/ntuser/desktop.c =================================================================== --- win32ss/user/ntuser/desktop.c (revision 73885) +++ win32ss/user/ntuser/desktop.c (working copy) @@ -1806,7 +1916,7 @@ { ERR("Failed to open desktop\n"); SetLastNtError(Status); - return 0; + return NULL; } TRACE("Opened desktop %S with handle 0x%p\n", ObjectAttributes->ObjectName->Buffer, Desktop); Index: win32ss/user/ntuser/desktop.h =================================================================== --- win32ss/user/ntuser/desktop.h (revision 73885) +++ win32ss/user/ntuser/desktop.h (working copy) @@ -181,11 +181,38 @@ HDC FASTCALL UserGetDesktopDC(ULONG,BOOL,BOOL); #define IntIsActiveDesktop(Desktop) \ - ((Desktop)->rpwinstaParent->ActiveDesktop == (Desktop)) + ((Desktop)->rpwinstaParent->ActiveDesktop == (Desktop)) HWND FASTCALL IntGetMessageWindow(VOID); PWND FASTCALL UserGetMessageWindow(VOID); +#if 0 +static __inline BOOL +UserIsDesktopWindow(IN PWND pWnd) +{ + // return (pWnd == UserGetDesktopWindow()); + return (pWnd && (pWnd->fnid == FNID_DESKTOP)); + // return (pWnd && (pWnd->fnid & FNID_DESKTOP)); +} + +static __inline BOOL +UserIsMessageWindow(IN PWND pWnd) +{ + // return (pWnd == UserGetMessageWindow()); + return (pWnd && (pWnd->fnid == FNID_MESSAGEWND)); + // return (pWnd && (pWnd->fnid & FNID_MESSAGEWND)); +} +#else + +#define UserIsDesktopWindow(pWnd) \ + ((pWnd) && ((pWnd)->fnid == FNID_DESKTOP)) + +#define UserIsMessageWindow(pWnd) \ + ((pWnd) && ((pWnd)->fnid == FNID_MESSAGEWND)) + +#endif + + static __inline PVOID DesktopHeapAlloc(IN PDESKTOP Desktop, IN SIZE_T Bytes) Index: win32ss/user/ntuser/message.c =================================================================== --- win32ss/user/ntuser/message.c (revision 73885) +++ win32ss/user/ntuser/message.c (working copy) @@ -616,9 +616,7 @@ // USER_REFERENCE_ENTRY Ref; // PTHREADINFO pti = PsGetCurrentThreadWin32Thread(); - if (!pWnd || - pWnd == UserGetDesktopWindow() || // pWnd->fnid == FNID_DESKTOP - pWnd == UserGetMessageWindow() ) // pWnd->fnid == FNID_MESSAGEWND + if (!pWnd || UserIsDesktopWindow(pWnd) || UserIsMessageWindow(pWnd)) return 0; TRACE("Internal Event Msg 0x%x hWnd 0x%p\n", msg, pWnd->head.h); Index: win32ss/user/ntuser/nonclient.c =================================================================== --- win32ss/user/ntuser/nonclient.c (revision 73885) +++ win32ss/user/ntuser/nonclient.c (working copy) @@ -1501,7 +1501,7 @@ if ((TopWnd->style & (WS_POPUP|WS_CHILD)) != WS_CHILD) break; parent = UserGetAncestor( TopWnd, GA_PARENT ); - if (!parent || parent == UserGetDesktopWindow()) break; + if (!parent || UserIsDesktopWindow(parent)) break; TopWnd = parent; } @@ -1885,7 +1885,7 @@ if (!pWnd) return HTNOWHERE; - if (pWnd == UserGetDesktopWindow()) // pWnd->fnid == FNID_DESKTOP) + if (UserIsDesktopWindow(pWnd)) { rcClient.left = rcClient.top = rcWindow.left = rcWindow.top = 0; rcWindow.right = UserGetSystemMetrics(SM_CXSCREEN); Index: win32ss/user/ntuser/painting.c =================================================================== --- win32ss/user/ntuser/painting.c (revision 73885) +++ win32ss/user/ntuser/painting.c (working copy) @@ -175,7 +175,7 @@ } // Send to all the children if this is the desktop window. - if ( Wnd == UserGetDesktopWindow() ) + if (UserIsDesktopWindow(Wnd)) { if ( Flags & RDW_ALLCHILDREN || ( !(Flags & RDW_NOCHILDREN) && Wnd->style & WS_CLIPCHILDREN)) @@ -569,7 +569,7 @@ if (!(Flags & RDW_NOCHILDREN) && Flags & RDW_ALLCHILDREN && - Wnd != UserGetDesktopWindow() ) + !UserIsDesktopWindow(Wnd) ) { PWND Child; @@ -1239,7 +1239,7 @@ PaintWnd->state &= ~WNDS_UPDATEDIRTY; Window = PaintWnd; - while( Window && Window != UserGetDesktopWindow()) + while (Window && !UserIsDesktopWindow(Window)) { // Role back and check for clip children, do not set if any. if (Window->spwndParent && !(Window->spwndParent->style & WS_CLIPCHILDREN)) @@ -1737,7 +1737,7 @@ RegionType = SIMPLEREGION; - if (Window != UserGetDesktopWindow()) // Window->fnid == FNID_DESKTOP + if (!UserIsDesktopWindow(Window)) { RECTL_vOffsetRect(&Rect, -Window->rcClient.left, @@ -1758,7 +1758,7 @@ return RegionType; } - if (Window != UserGetDesktopWindow()) // Window->fnid == FNID_DESKTOP + if (!UserIsDesktopWindow(Window)) { NtGdiOffsetRgn(hRgn, -Window->rcClient.left, @@ -1808,7 +1808,7 @@ if (IntIntersectWithParents(Window, pRect)) { - if (Window != UserGetDesktopWindow()) // Window->fnid == FNID_DESKTOP + if (!UserIsDesktopWindow(Window)) { RECTL_vOffsetRect(pRect, -Window->rcClient.left, @@ -2430,9 +2461,8 @@ if (hwnd) { - if (!(Window = UserGetWindowObject(hwnd)) || // FIXME: - Window == UserGetDesktopWindow() || // pWnd->fnid == FNID_DESKTOP - Window == UserGetMessageWindow() ) // pWnd->fnid == FNID_MESSAGEWND + if (!(Window = UserGetWindowObject(hwnd)) || + UserIsDesktopWindow(Window) || UserIsMessageWindow(Window)) { goto Exit; } Index: win32ss/user/ntuser/scrollbar.c =================================================================== --- win32ss/user/ntuser/scrollbar.c (revision 73885) +++ win32ss/user/ntuser/scrollbar.c (working copy) @@ -1161,9 +1161,8 @@ TRACE("Enter NtUserEnableScrollBar\n"); UserEnterExclusive(); - if (!(Window = UserGetWindowObject(hWnd)) || // FIXME: - Window == UserGetDesktopWindow() || // pWnd->fnid == FNID_DESKTOP - Window == UserGetMessageWindow() ) // pWnd->fnid == FNID_MESSAGEWND + if (!(Window = UserGetWindowObject(hWnd)) || + UserIsDesktopWindow(Window) || UserIsMessageWindow(Window)) { RETURN(FALSE); } @@ -1247,9 +1246,8 @@ TRACE("Enter NtUserSetScrollInfo\n"); UserEnterExclusive(); - if(!(Window = UserGetWindowObject(hWnd)) || // FIXME: - Window == UserGetDesktopWindow() || // pWnd->fnid == FNID_DESKTOP - Window == UserGetMessageWindow() ) // pWnd->fnid == FNID_MESSAGEWND + if(!(Window = UserGetWindowObject(hWnd)) || + UserIsDesktopWindow(Window) || UserIsMessageWindow(Window)) { RETURN( 0); } Index: win32ss/user/ntuser/scrollex.c =================================================================== --- win32ss/user/ntuser/scrollex.c (revision 73885) +++ win32ss/user/ntuser/scrollex.c (working copy) @@ -392,7 +392,7 @@ { UserRefObjectCo(Child, &WndRef); - if (Window->spwndParent == UserGetDesktopWindow()) // Window->spwndParent->fnid == FNID_DESKTOP ) + if (UserIsDesktopWindow(Window->spwndParent)) lParam = MAKELONG(Child->rcClient.left, Child->rcClient.top); else lParam = MAKELONG(rcChild.left + dx, rcChild.top + dy); Index: win32ss/user/ntuser/window.c =================================================================== --- win32ss/user/ntuser/window.c (revision 73885) +++ win32ss/user/ntuser/window.c (working copy) @@ -1125,8 +1125,7 @@ /* Link the window with its new siblings */ IntLinkHwnd( Wnd, ((0 == (Wnd->ExStyle & WS_EX_TOPMOST) && - WndNewParent == UserGetDesktopWindow() ) ? HWND_TOP : HWND_TOPMOST ) ); - + UserIsDesktopWindow(WndNewParent) ) ? HWND_TOP : HWND_TOPMOST ) ); } if ( WndNewParent == co_GetDesktopWindow(Wnd) && @@ -1158,7 +1157,7 @@ } } - if (WndOldParent == UserGetMessageWindow() || WndNewParent == UserGetMessageWindow()) + if (UserIsMessageWindow(WndOldParent) || UserIsMessageWindow(WndNewParent)) swFlags |= SWP_NOACTIVATE; IntNotifyWinEvent(EVENT_OBJECT_PARENTCHANGE, Wnd ,OBJID_WINDOW, CHILDID_SELF, WEF_SETBYWNDPTI); @@ -1437,7 +1436,7 @@ if ( (pWindow->style & (WS_CHILD | WS_POPUP)) == WS_CHILD && !(pWindow->ExStyle & WS_EX_NOPARENTNOTIFY)) { - if (VerifyWnd(pWindow->spwndParent) && pWindow->spwndParent != UserGetDesktopWindow()) + if (VerifyWnd(pWindow->spwndParent) && !UserIsDesktopWindow(pWindow->spwndParent)) { USER_REFERENCE_ENTRY Ref; UserRefObjectCo(pWindow->spwndParent, &Ref); @@ -2252,7 +2251,7 @@ IntSendParentNotify(Window, WM_CREATE); /* Notify the shell that a new window was created */ - if (Window->spwndParent == UserGetDesktopWindow() && + if (UserIsDesktopWindow(Window->spwndParent) && Window->spwndOwner == NULL && (Window->style & WS_VISIBLE) && (!(Window->ExStyle & WS_EX_TOOLWINDOW) || @@ -3452,7 +3451,7 @@ RETURN(FALSE); } - if(!(WndListView = UserGetWindowObject(hwndListView))) + if (!(WndListView = UserGetWindowObject(hwndListView))) { RETURN(FALSE); } @@ -3623,7 +3622,7 @@ co_IntSendMessage(hWnd, WM_STYLECHANGING, GWL_STYLE, (LPARAM) &Style); /* WS_CLIPSIBLINGS can't be reset on top-level windows */ - if (Window->spwndParent == UserGetDesktopWindow()) Style.styleNew |= WS_CLIPSIBLINGS; + if (UserIsDesktopWindow(Window->spwndParent)) Style.styleNew |= WS_CLIPSIBLINGS; /* WS_MINIMIZE can't be reset */ if (OldValue & WS_MINIMIZE) Style.styleNew |= WS_MINIMIZE; /* Fixes wine FIXME: changing WS_DLGFRAME | WS_THICKFRAME is supposed to change WS_EX_WINDOWEDGE too */ Index: win32ss/user/ntuser/winpos.c =================================================================== --- win32ss/user/ntuser/winpos.c (revision 73885) +++ win32ss/user/ntuser/winpos.c (working copy) @@ -99,7 +99,7 @@ Rect->bottom = UserGetSystemMetrics(SM_CYMINIMIZED); return; } - if ( Wnd != UserGetDesktopWindow()) // Wnd->fnid != FNID_DESKTOP ) + if (!UserIsDesktopWindow(Wnd)) { *Rect = Wnd->rcClient; RECTL_vOffsetRect(Rect, -Wnd->rcClient.left, -Wnd->rcClient.top); @@ -122,7 +122,7 @@ ASSERT( Wnd ); ASSERT( Rect ); if (!Wnd) return FALSE; - if ( Wnd != UserGetDesktopWindow()) // Wnd->fnid != FNID_DESKTOP ) + if (!UserIsDesktopWindow(Wnd)) { *Rect = Wnd->rcWindow; } @@ -151,7 +151,7 @@ Delta.x = Delta.y = 0; mirror_from = mirror_to = FALSE; - if (FromWnd && FromWnd != UserGetDesktopWindow()) // FromWnd->fnid != FNID_DESKTOP) + if (FromWnd && !UserIsDesktopWindow(FromWnd)) { if (FromWnd->ExStyle & WS_EX_LAYOUTRTL) { @@ -164,7 +164,7 @@ Delta.y = FromWnd->rcClient.top; } - if (ToWnd && ToWnd != UserGetDesktopWindow()) // ToWnd->fnid != FNID_DESKTOP) + if (ToWnd && !UserIsDesktopWindow(ToWnd)) { if (ToWnd->ExStyle & WS_EX_LAYOUTRTL) { @@ -255,7 +255,7 @@ } VOID -SelectWindowRgn( PWND Window, HRGN hRgnClip) +SelectWindowRgn(PWND Window, HRGN hRgnClip) { if (Window->hrgnClip) { @@ -267,7 +267,7 @@ if (hRgnClip > HRGN_WINDOW) { - /*if (Window != UserGetDesktopWindow()) // Window->fnid != FNID_DESKTOP) + /*if (!UserIsDesktopWindow(Window)) { NtGdiOffsetRgn(hRgnClip, Window->rcWindow.left, Window->rcWindow.top); }*/ @@ -480,7 +480,7 @@ POINT Size; RECTL Rect = *RestoreRect; - if (Wnd->spwndParent && Wnd->spwndParent != UserGetDesktopWindow()) + if (Wnd->spwndParent && !UserIsDesktopWindow(Wnd->spwndParent)) { RECTL_vOffsetRect(&Rect, -Wnd->spwndParent->rcClient.left, @@ -782,7 +782,7 @@ int x, y, xspacing, yspacing; pwndParent = Window->spwndParent; - if (pwndParent == UserGetDesktopWindow()) + if (UserIsDesktopWindow(pwndParent)) { ERR("FIXME: Parent is Desktop, Min off screen!\n"); /* FIXME: ReactOS doesn't support iconic minimize to desktop */ @@ -1972,7 +1972,7 @@ 0, RDW_VALIDATE | RDW_NOFRAME | RDW_NOERASE | RDW_NOINTERNALPAINT | RDW_ALLCHILDREN); - if (Window->spwndParent == UserGetDesktopWindow()) + if (UserIsDesktopWindow(Window->spwndParent)) co_IntShellHookNotify(HSHELL_WINDOWDESTROYED, (WPARAM)Window->head.h, 0); Window->style &= ~WS_VISIBLE; //IntSetStyle( Window, 0, WS_VISIBLE ); @@ -1981,7 +1981,7 @@ } else if (WinPos.flags & SWP_SHOWWINDOW) { - if (Window->spwndParent == UserGetDesktopWindow() && + if (UserIsDesktopWindow(Window->spwndParent) && Window->spwndOwner == NULL && (!(Window->ExStyle & WS_EX_TOOLWINDOW) || (Window->ExStyle & WS_EX_APPWINDOW))) @@ -2330,7 +2330,7 @@ co_IntSendMessageNoWait(UserHMGetHandle(Wnd), WM_SIZE, wParam, lParam); - if (Wnd->spwndParent == UserGetDesktopWindow()) // Wnd->spwndParent->fnid == FNID_DESKTOP ) + if (UserIsDesktopWindow(Wnd->spwndParent)) lParam = MAKELONG(Wnd->rcClient.left, Wnd->rcClient.top); else lParam = MAKELONG(Wnd->rcClient.left-Wnd->spwndParent->rcClient.left, Wnd->rcClient.top-Wnd->spwndParent->rcClient.top); @@ -2582,7 +2582,7 @@ { if ( Wnd == pti->MessageQueue->spwndActive && pti->MessageQueue == IntGetFocusMessageQueue() ) { - if ( Wnd->spwndParent == UserGetDesktopWindow()) + if (UserIsDesktopWindow(Wnd->spwndParent)) { if (!ActivateOtherWindowMin(Wnd)) { @@ -2599,7 +2599,8 @@ if (Wnd == pti->MessageQueue->spwndFocus) { Parent = Wnd->spwndParent; - if (Wnd->spwndParent == UserGetDesktopWindow()) Parent = 0; + if (UserIsDesktopWindow(Wnd->spwndParent)) + Parent = 0; co_UserSetFocus(Parent); } // Hide, just return. @@ -2753,7 +2754,7 @@ Pt.x = x; Pt.y = y; - if (Parent != UserGetDesktopWindow()) + if (!UserIsDesktopWindow(Parent)) { Pt.x += Parent->rcClient.left; Pt.y += Parent->rcClient.top; @@ -2795,7 +2796,7 @@ Pt.x = x; Pt.y = y; - if (Parent != UserGetDesktopWindow()) + if (!UserIsDesktopWindow(Parent)) { if (Parent->ExStyle & WS_EX_LAYOUTRTL) Pt.x = Parent->rcClient.right - Pt.x; @@ -3059,9 +3060,7 @@ } pWnd = UserGetWindowObject(Wnd); - if ( !pWnd || // FIXME: - pWnd == UserGetDesktopWindow() || // pWnd->fnid == FNID_DESKTOP - pWnd == UserGetMessageWindow() ) // pWnd->fnid == FNID_MESSAGEWND + if (!pWnd || UserIsDesktopWindow(pWnd) || UserIsMessageWindow(pWnd)) { goto Exit; } @@ -3072,9 +3071,7 @@ WndInsertAfter != HWND_NOTOPMOST ) { pWndIA = UserGetWindowObject(WndInsertAfter); - if ( !pWndIA || - pWndIA == UserGetDesktopWindow() || - pWndIA == UserGetMessageWindow() ) + if (!pWndIA || UserIsDesktopWindow(pWndIA) || UserIsMessageWindow(pWndIA)) { goto Exit; } @@ -3221,9 +3218,7 @@ UserEnterExclusive(); pWnd = UserGetWindowObject(hWnd); - if ( !pWnd || // FIXME: - pWnd == UserGetDesktopWindow() || // pWnd->fnid == FNID_DESKTOP - pWnd == UserGetMessageWindow() ) // pWnd->fnid == FNID_MESSAGEWND + if (!pWnd || UserIsDesktopWindow(pWnd) || UserIsMessageWindow(pWnd)) { goto Exit; } @@ -3302,9 +3297,8 @@ TRACE("Enter NtUserSetWindowPos\n"); UserEnterExclusive(); - if (!(Window = UserGetWindowObject(hWnd)) || // FIXME: - Window == UserGetDesktopWindow() || // pWnd->fnid == FNID_DESKTOP - Window == UserGetMessageWindow() ) // pWnd->fnid == FNID_MESSAGEWND + if (!(Window = UserGetWindowObject(hWnd)) || + UserIsDesktopWindow(Window) || UserIsMessageWindow(Window)) { ERR("NtUserSetWindowPos bad window handle!\n"); RETURN(FALSE); @@ -3316,8 +3310,7 @@ hWndInsertAfter != HWND_NOTOPMOST ) { if (!(pWndIA = UserGetWindowObject(hWndInsertAfter)) || - pWndIA == UserGetDesktopWindow() || - pWndIA == UserGetMessageWindow() ) + UserIsDesktopWindow(pWndIA) || UserIsMessageWindow(pWndIA)) { ERR("NtUserSetWindowPos bad insert window handle!\n"); RETURN(FALSE); @@ -3370,9 +3363,8 @@ TRACE("Enter NtUserSetWindowRgn\n"); UserEnterExclusive(); - if (!(Window = UserGetWindowObject(hWnd)) || // FIXME: - Window == UserGetDesktopWindow() || // pWnd->fnid == FNID_DESKTOP - Window == UserGetMessageWindow() ) // pWnd->fnid == FNID_MESSAGEWND + if (!(Window = UserGetWindowObject(hWnd)) || + UserIsDesktopWindow(Window) || UserIsMessageWindow(Window)) { RETURN( 0); } @@ -3432,8 +3424,7 @@ UserEnterExclusive(); if (!(Wnd = UserGetWindowObject(hwnd)) || // FIXME: - Wnd == UserGetDesktopWindow() || // pWnd->fnid == FNID_DESKTOP - Wnd == UserGetMessageWindow() ) // pWnd->fnid == FNID_MESSAGEWND + UserIsDesktopWindow(Wnd) || UserIsMessageWindow(Wnd)) { RETURN( FALSE); } @@ -3501,9 +3492,8 @@ TRACE("Enter NtUserSetWindowPlacement\n"); UserEnterExclusive(); - if (!(Wnd = UserGetWindowObject(hWnd)) || // FIXME: - Wnd == UserGetDesktopWindow() || // pWnd->fnid == FNID_DESKTOP - Wnd == UserGetMessageWindow() ) // pWnd->fnid == FNID_MESSAGEWND + if (!(Wnd = UserGetWindowObject(hWnd)) || + UserIsDesktopWindow(Wnd) || UserIsMessageWindow(Wnd)) { RETURN( FALSE); } @@ -3552,9 +3542,8 @@ TRACE("Enter NtUserShowWindowAsync\n"); UserEnterExclusive(); - if (!(Window = UserGetWindowObject(hWnd)) || // FIXME: - Window == UserGetDesktopWindow() || // pWnd->fnid == FNID_DESKTOP - Window == UserGetMessageWindow() ) // pWnd->fnid == FNID_MESSAGEWND + if (!(Window = UserGetWindowObject(hWnd)) || + UserIsDesktopWindow(Window) || UserIsMessageWindow(Window)) { RETURN(FALSE); } @@ -3592,9 +3581,8 @@ TRACE("Enter NtUserShowWindow hWnd %p SW_ %d\n",hWnd, nCmdShow); UserEnterExclusive(); - if (!(Window = UserGetWindowObject(hWnd)) || // FIXME: - Window == UserGetDesktopWindow() || // pWnd->fnid == FNID_DESKTOP - Window == UserGetMessageWindow() ) // pWnd->fnid == FNID_MESSAGEWND + if (!(Window = UserGetWindowObject(hWnd)) || + UserIsDesktopWindow(Window) || UserIsMessageWindow(Window)) { RETURN(FALSE); }