From d030c9eef00d6bf3e1ab90ef0cb0222366302d09 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Sat, 19 May 2012 04:40:37 +0000 Subject: [PATCH] [Win32SS] - Fix test_child_window_from_point results. - Turn on process layout. - Miscellaneous changes and fixups. svn path=/trunk/; revision=56609 --- reactos/win32ss/user/ntuser/ntstubs.c | 36 ++-- reactos/win32ss/user/ntuser/winpos.c | 196 +++++++++++++------ reactos/win32ss/user/ntuser/winpos.h | 3 +- reactos/win32ss/user/user32/misc/stubs.c | 22 --- reactos/win32ss/user/user32/user32.spec | 2 +- reactos/win32ss/user/user32/windows/window.c | 23 +-- 6 files changed, 152 insertions(+), 130 deletions(-) diff --git a/reactos/win32ss/user/ntuser/ntstubs.c b/reactos/win32ss/user/ntuser/ntstubs.c index 6b8709eadb6..9e7460e500d 100644 --- a/reactos/win32ss/user/ntuser/ntstubs.c +++ b/reactos/win32ss/user/ntuser/ntstubs.c @@ -908,17 +908,6 @@ NtUserPaintMenuBar( return 0; } -BOOL -APIENTRY -NtUserGetLayeredWindowAttributes( - HWND hwnd, - COLORREF *pcrKey, - BYTE *pbAlpha, - DWORD *pdwFlags) -{ - STUB; - return 0; -} DWORD APIENTRY @@ -1015,19 +1004,6 @@ NtUserLockWindowUpdate(HWND hWnd) return 0; } -/* - * @unimplemented - */ -HWND APIENTRY -NtUserRealChildWindowFromPoint(HWND Parent, - LONG x, - LONG y) -{ - STUB - - return 0; -} - /* * @unimplemented */ @@ -1040,6 +1016,18 @@ NtUserSetImeOwnerWindow(DWORD Unknown0, return 0; } +BOOL +APIENTRY +NtUserGetLayeredWindowAttributes( + HWND hwnd, + COLORREF *pcrKey, + BYTE *pbAlpha, + DWORD *pdwFlags) +{ + STUB; + return 0; +} + /* * @unimplemented */ diff --git a/reactos/win32ss/user/ntuser/winpos.c b/reactos/win32ss/user/ntuser/winpos.c index d69e466d323..ab4eb258c11 100644 --- a/reactos/win32ss/user/ntuser/winpos.c +++ b/reactos/win32ss/user/ntuser/winpos.c @@ -150,10 +150,8 @@ BOOL FASTCALL can_activate_window( PWND Wnd OPTIONAL) if (!Wnd) return FALSE; style = Wnd->style; - if (!(style & WS_VISIBLE) && - Wnd->head.pti->pEThread->ThreadsProcess != CsrProcess) return FALSE; - if ((style & WS_MINIMIZE) && - Wnd->head.pti->pEThread->ThreadsProcess != CsrProcess) return FALSE; + if (!(style & WS_VISIBLE)) return FALSE; + if (style & WS_MINIMIZE) return FALSE; if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return FALSE; return TRUE; /* FIXME: This window could be disable because the child that closed @@ -1783,8 +1781,10 @@ co_WinPosSendSizeMove(PWND Wnd) WPARAM wParam = SIZE_RESTORED; IntGetClientRect(Wnd, &Rect); + lParam = MAKELONG(Rect.right-Rect.left, Rect.bottom-Rect.top); Wnd->state &= ~WNDS_SENDSIZEMOVEMSGS; + if (Wnd->style & WS_MAXIMIZE) { wParam = SIZE_MAXIMIZED; @@ -1792,9 +1792,10 @@ co_WinPosSendSizeMove(PWND Wnd) else if (Wnd->style & WS_MINIMIZE) { wParam = SIZE_MINIMIZED; + lParam = 0; } - co_IntSendMessageNoWait(UserHMGetHandle(Wnd), WM_SIZE, wParam, MAKELONG(Rect.right-Rect.left, Rect.bottom-Rect.top)); + co_IntSendMessageNoWait(UserHMGetHandle(Wnd), WM_SIZE, wParam, lParam); if (Wnd->spwndParent == UserGetDesktopWindow()) // Wnd->spwndParent->fnid != FNID_DESKTOP ) lParam = MAKELONG(Wnd->rcClient.left, Wnd->rcClient.top); @@ -2010,8 +2011,7 @@ co_WinPosSearchChildren( UserReferenceObject(ScopeWin); - if (Point->x - ScopeWin->rcClient.left < ScopeWin->rcClient.right && - Point->y - ScopeWin->rcClient.top < ScopeWin->rcClient.bottom ) + if ( RECTL_bPointInRect(&ScopeWin->rcClient, Point->x, Point->y) ) { List = IntWinListChildren(ScopeWin); if(List) @@ -2077,6 +2077,99 @@ co_WinPosWindowFromPoint(PWND ScopeWin, POINT *WinPoint, USHORT* HitTest) return Window; } +PWND FASTCALL +IntRealChildWindowFromPoint(PWND Parent, LONG x, LONG y) +{ + POINTL Pt; + HWND *List, *phWnd; + PWND pwndHit = NULL; + + Pt.x = x; + Pt.y = y; + + if (Parent != UserGetDesktopWindow()) + { + Pt.x += Parent->rcClient.left; + Pt.y += Parent->rcClient.top; + } + + if (!IntPtInWindow(Parent, Pt.x, Pt.y)) return NULL; + + if ((List = IntWinListChildren(Parent))) + { + for (phWnd = List; *phWnd; phWnd++) + { + PWND Child; + if ((Child = UserGetWindowObject(*phWnd))) + { + if ( Child->style & WS_VISIBLE && IntPtInWindow(Child, Pt.x, Pt.y) ) + { + if ( Child->pcls->atomClassName != gpsi->atomSysClass[ICLS_BUTTON] || + (Child->style & BS_TYPEMASK) != BS_GROUPBOX ) + { + ExFreePool(List); + return Child; + } + pwndHit = Child; + } + } + } + ExFreePool(List); + } + return pwndHit ? pwndHit : Parent; +} + +PWND APIENTRY +IntChildWindowFromPointEx(PWND Parent, LONG x, LONG y, UINT uiFlags) +{ + POINTL Pt; + HWND *List, *phWnd; + PWND pwndHit = NULL; + + Pt.x = x; + Pt.y = y; + + if (Parent != UserGetDesktopWindow()) + { + if (Parent->ExStyle & WS_EX_LAYOUTRTL) + Pt.x = Parent->rcClient.right - Pt.x; + else + Pt.x += Parent->rcClient.left; + Pt.y += Parent->rcClient.top; + } + + if (!IntPtInWindow(Parent, Pt.x, Pt.y)) return NULL; + + if ((List = IntWinListChildren(Parent))) + { + for (phWnd = List; *phWnd; phWnd++) + { + PWND Child; + if ((Child = UserGetWindowObject(*phWnd))) + { + if (uiFlags & (CWP_SKIPINVISIBLE|CWP_SKIPDISABLED)) + { + if (!(Child->style & WS_VISIBLE) && (uiFlags & CWP_SKIPINVISIBLE)) continue; + if ((Child->style & WS_DISABLED) && (uiFlags & CWP_SKIPDISABLED)) continue; + } + + if (uiFlags & CWP_SKIPTRANSPARENT) + { + if (Child->ExStyle & WS_EX_TRANSPARENT) continue; + } + + if (IntPtInWindow(Child, Pt.x, Pt.y)) + { + pwndHit = Child; + break; + } + } + } + ExFreePool(List); + } + return pwndHit ? pwndHit : Parent; +} + HDWP FASTCALL IntDeferWindowPos( HDWP hdwp, @@ -2191,7 +2284,7 @@ BOOL FASTCALL IntEndDeferWindowPosEx( HDWP hdwp, BOOL sAsync ) winpos->pos.hwnd, winpos->pos.hwndInsertAfter, winpos->pos.x, winpos->pos.y, winpos->pos.cx, winpos->pos.cy, winpos->pos.flags); - pwnd = UserGetWindowObject(winpos->pos.hwnd); + pwnd = (PWND)UserGetObject(gHandleTable, winpos->pos.hwnd, otWindow); if (!pwnd) continue; @@ -2207,7 +2300,7 @@ BOOL FASTCALL IntEndDeferWindowPosEx( HDWP hdwp, BOOL sAsync ) /* Yes it's a pointer inside Win32k! */ lRes = co_IntSendMessageNoWait( winpos->pos.hwnd, WM_ASYNC_SETWINDOWPOS, 0, (LPARAM)ppos); /* We handle this the same way as Event Hooks and Hooks. */ - if ( -1 == (int) lRes ) + if ( !lRes ) { ExFreePoolWithTag(ppos, USERTAG_SWP); } @@ -2240,61 +2333,16 @@ NtUserChildWindowFromPointEx(HWND hwndParent, LONG y, UINT uiFlags) { - PWND Parent; - POINTL Pt; - HWND Ret; - HWND *List, *phWnd; - - if(!(Parent = UserGetWindowObject(hwndParent))) + PWND pwndParent; + TRACE("Enter NtUserChildWindowFromPointEx\n"); + UserEnterExclusive(); + if ((pwndParent = UserGetWindowObject(hwndParent))) { - return NULL; + pwndParent = IntChildWindowFromPointEx(pwndParent, x, y, uiFlags); } - - Pt.x = x; - Pt.y = y; - - if(Parent->head.h != IntGetDesktopWindow()) - { - Pt.x += Parent->rcClient.left; - Pt.y += Parent->rcClient.top; - } - - if(!IntPtInWindow(Parent, Pt.x, Pt.y)) - { - return NULL; - } - - Ret = Parent->head.h; - if((List = IntWinListChildren(Parent))) - { - for(phWnd = List; *phWnd; phWnd++) - { - PWND Child; - if((Child = UserGetWindowObject(*phWnd))) - { - if(!(Child->style & WS_VISIBLE) && (uiFlags & CWP_SKIPINVISIBLE)) - { - continue; - } - if((Child->style & WS_DISABLED) && (uiFlags & CWP_SKIPDISABLED)) - { - continue; - } - if((Child->ExStyle & WS_EX_TRANSPARENT) && (uiFlags & CWP_SKIPTRANSPARENT)) - { - continue; - } - if(IntPtInWindow(Child, Pt.x, Pt.y)) - { - Ret = Child->head.h; - break; - } - } - } - ExFreePool(List); - } - - return Ret; + UserLeave(); + TRACE("Leave NtUserChildWindowFromPointEx\n"); + return pwndParent ? UserHMGetHandle(pwndParent) : NULL; } /* @@ -2521,9 +2569,9 @@ NtUserMinMaximize( goto Exit; } - co_WinPosMinMaximize(pWnd, cmd, &NewPos); + SwFlags = co_WinPosMinMaximize(pWnd, cmd, &NewPos); - SwFlags = Hide ? SWP_NOACTIVATE|SWP_NOZORDER|SWP_FRAMECHANGED : SWP_NOZORDER|SWP_FRAMECHANGED; + SwFlags |= Hide ? SWP_NOACTIVATE : 0; co_WinPosSetWindowPos( pWnd, NULL, @@ -2558,6 +2606,26 @@ NtUserMoveWindow( SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW)); } +/* + * @implemented + */ +HWND APIENTRY +NtUserRealChildWindowFromPoint(HWND Parent, + LONG x, + LONG y) +{ + PWND pwndParent; + TRACE("Enter NtUserRealChildWindowFromPoint\n"); + UserEnterShared(); + if ((pwndParent = UserGetWindowObject(Parent))) + { + pwndParent = IntRealChildWindowFromPoint(pwndParent, x, y); + } + UserLeave(); + TRACE("Leave NtUserRealChildWindowFromPoint\n"); + return pwndParent ? UserHMGetHandle(pwndParent) : NULL; +} + /* * @implemented */ diff --git a/reactos/win32ss/user/ntuser/winpos.h b/reactos/win32ss/user/ntuser/winpos.h index 492529d272e..270214659b0 100644 --- a/reactos/win32ss/user/ntuser/winpos.h +++ b/reactos/win32ss/user/ntuser/winpos.h @@ -53,4 +53,5 @@ BOOLEAN FASTCALL co_WinPosSetWindowPos(PWND Wnd, HWND WndInsertAfter, INT x, INT BOOLEAN FASTCALL co_WinPosShowWindow(PWND Window, INT Cmd); void FASTCALL co_WinPosSendSizeMove(PWND Window); PWND FASTCALL co_WinPosWindowFromPoint(PWND ScopeWin, POINT *WinPoint, USHORT* HitTest); -VOID FASTCALL co_WinPosActivateOtherWindow(PWND Window); +VOID FASTCALL co_WinPosActivateOtherWindow(PWND); +PWND FASTCALL IntRealChildWindowFromPoint(PWND,LONG,LONG); diff --git a/reactos/win32ss/user/user32/misc/stubs.c b/reactos/win32ss/user/user32/misc/stubs.c index 76c5295fc44..0b95c562471 100644 --- a/reactos/win32ss/user/user32/misc/stubs.c +++ b/reactos/win32ss/user/user32/misc/stubs.c @@ -69,28 +69,6 @@ GetAppCompatFlags2(HTASK hTask) return pci->dwCompatFlags2; } -/* - * @unimplemented - */ -UINT -WINAPI -GetInternalWindowPos( - HWND hwnd, - LPRECT rectWnd, - LPPOINT ptIcon - ) -{ - WINDOWPLACEMENT wndpl; - - if (GetWindowPlacement(hwnd, &wndpl)) - { - if (rectWnd) *rectWnd = wndpl.rcNormalPosition; - if (ptIcon) *ptIcon = wndpl.ptMinPosition; - return wndpl.showCmd; - } - return 0; -} - /* * @unimplemented */ diff --git a/reactos/win32ss/user/user32/user32.spec b/reactos/win32ss/user/user32/user32.spec index 37f63c5e941..5a2ae820c0b 100644 --- a/reactos/win32ss/user/user32/user32.spec +++ b/reactos/win32ss/user/user32/user32.spec @@ -286,7 +286,7 @@ @ stdcall GetIconInfo(long ptr) @ stdcall GetInputDesktop() @ stdcall GetInputState() -@ stdcall GetInternalWindowPos(long ptr ptr) ; direct call NtUserGetInternalWindowPos +@ stdcall GetInternalWindowPos(long ptr ptr) NtUserGetInternalWindowPos @ stdcall GetKBCodePage() @ stdcall GetKeyNameTextA(long ptr long) @ stdcall GetKeyNameTextW(long ptr long) diff --git a/reactos/win32ss/user/user32/windows/window.c b/reactos/win32ss/user/user32/windows/window.c index 7d0bceb350e..6dc86486660 100644 --- a/reactos/win32ss/user/user32/windows/window.c +++ b/reactos/win32ss/user/user32/windows/window.c @@ -1028,21 +1028,12 @@ GetParent(HWND hWnd) /* - * @unimplemented + * @implemented */ BOOL WINAPI GetProcessDefaultLayout(DWORD *pdwDefaultLayout) { - if (!pdwDefaultLayout) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - UNIMPLEMENTED; - - *pdwDefaultLayout = 0; - return TRUE; +return (BOOL)NtUserCallOneParam( (DWORD_PTR)pdwDefaultLayout, ONEPARAM_ROUTINE_GETPROCDEFLAYOUT); } @@ -1659,7 +1650,7 @@ HWND WINAPI RealChildWindowFromPoint(HWND hwndParent, POINT ptParentClientCoords) { - return ChildWindowFromPointEx(hwndParent, ptParentClientCoords, CWP_SKIPTRANSPARENT | CWP_SKIPINVISIBLE); + return NtUserRealChildWindowFromPoint(hwndParent, ptParentClientCoords.x, ptParentClientCoords.y); } /* @@ -1673,16 +1664,12 @@ SetForegroundWindow(HWND hWnd) /* - * @unimplemented + * @implemented */ BOOL WINAPI SetProcessDefaultLayout(DWORD dwDefaultLayout) { - if (dwDefaultLayout == 0) - return TRUE; - - UNIMPLEMENTED; - return FALSE; +return NtUserCallOneParam( (DWORD_PTR)dwDefaultLayout, ONEPARAM_ROUTINE_SETPROCDEFLAYOUT); }