From 07151bdc1a36acaafe846d0f03170e46688e19df Mon Sep 17 00:00:00 2001 From: Gunnar Dalsnes Date: Wed, 7 Sep 2005 07:53:31 +0000 Subject: [PATCH] make co_WinPosShowWindow take pWnd, not hWnd add co_ to some funcs svn path=/trunk/; revision=17713 --- reactos/subsys/win32k/include/userfuncs.h | 2 - reactos/subsys/win32k/include/winpos.h | 2 +- reactos/subsys/win32k/ntuser/scrollbar.c | 2 +- reactos/subsys/win32k/ntuser/window.c | 48 +++++++++++++++-------- reactos/subsys/win32k/ntuser/winpos.c | 33 ++++++---------- 5 files changed, 44 insertions(+), 43 deletions(-) diff --git a/reactos/subsys/win32k/include/userfuncs.h b/reactos/subsys/win32k/include/userfuncs.h index 378bed38d9f..e69a7ebde0b 100644 --- a/reactos/subsys/win32k/include/userfuncs.h +++ b/reactos/subsys/win32k/include/userfuncs.h @@ -93,8 +93,6 @@ co_DestroyThreadWindows(struct _ETHREAD *Thread); HWND FASTCALL UserGetShellWindow(); -HWND FASTCALL UserSetParent(HWND hWndChild, HWND hWndNewParent); - HWND FASTCALL UserGetWindow(HWND hWnd, UINT Relationship); HDC FASTCALL diff --git a/reactos/subsys/win32k/include/winpos.h b/reactos/subsys/win32k/include/winpos.h index 9be9f705d8f..fe6861d8c3a 100644 --- a/reactos/subsys/win32k/include/winpos.h +++ b/reactos/subsys/win32k/include/winpos.h @@ -29,7 +29,7 @@ BOOLEAN FASTCALL co_WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx, INT cy, UINT flags); BOOLEAN FASTCALL -co_WinPosShowWindow(HWND Wnd, INT Cmd); +co_WinPosShowWindow(PWINDOW_OBJECT Window, INT Cmd); USHORT FASTCALL co_WinPosWindowFromPoint(PWINDOW_OBJECT ScopeWin, PUSER_MESSAGE_QUEUE OnlyHitTests, POINT *WinPoint, PWINDOW_OBJECT* Window); diff --git a/reactos/subsys/win32k/ntuser/scrollbar.c b/reactos/subsys/win32k/ntuser/scrollbar.c index 50d433247db..2f412a4f65e 100644 --- a/reactos/subsys/win32k/ntuser/scrollbar.c +++ b/reactos/subsys/win32k/ntuser/scrollbar.c @@ -853,7 +853,7 @@ co_UserShowScrollBar(PWINDOW_OBJECT Window, int wBar, DWORD bShow) { IntUpdateSBInfo(Window, SB_CTL); - co_WinPosShowWindow(Window->hSelf, bShow ? SW_SHOW : SW_HIDE); + co_WinPosShowWindow(Window, bShow ? SW_SHOW : SW_HIDE); return( TRUE); } diff --git a/reactos/subsys/win32k/ntuser/window.c b/reactos/subsys/win32k/ntuser/window.c index ff3e17537f8..b3c49bc0961 100644 --- a/reactos/subsys/win32k/ntuser/window.c +++ b/reactos/subsys/win32k/ntuser/window.c @@ -913,7 +913,7 @@ IntSetOwner(HWND hWnd, HWND hWndNewOwner) } PWINDOW_OBJECT FASTCALL -IntSetParent(PWINDOW_OBJECT Wnd, PWINDOW_OBJECT WndNewParent) +co_IntSetParent(PWINDOW_OBJECT Wnd, PWINDOW_OBJECT WndNewParent) { PWINDOW_OBJECT WndOldParent, Sibling, InsertAfter; HWND hWnd, hWndNewParent, hWndOldParent; @@ -930,7 +930,7 @@ IntSetParent(PWINDOW_OBJECT Wnd, PWINDOW_OBJECT WndNewParent) * Windows hides the window first, then shows it again * including the WM_SHOWWINDOW messages and all */ - WasVisible = co_WinPosShowWindow(hWnd, SW_HIDE); + WasVisible = co_WinPosShowWindow(Wnd, SW_HIDE); /* Validate that window and parent still exist */ if (!IntIsWindow(hWnd) || !IntIsWindow(hWndNewParent)) @@ -1984,14 +1984,16 @@ co_IntCreateWindowEx(DWORD dwExStyle, { co_UserShowScrollBar(Window, SB_HORZ, TRUE); } - UserDereferenceWindowObjectCo(Window); if (dwStyle & WS_VISIBLE) { DPRINT("IntCreateWindow(): About to show window\n"); - co_WinPosShowWindow(Window->hSelf, dwShowMode); + co_WinPosShowWindow(Window, dwShowMode); } + //faxme: temp hack + UserDereferenceWindowObjectCo(Window); + DPRINT("IntCreateWindow(): = %X\n", Handle); DPRINT("WindowObject->SystemMenu = 0x%x\n", Window->SystemMenu); return((HWND)Handle); @@ -2098,6 +2100,8 @@ BOOLEAN FASTCALL co_UserDestroyWindow(PWINDOW_OBJECT Window) { BOOLEAN isChild; + ASSERT_REFS(Window); + if (Window == NULL) { return FALSE; @@ -2113,7 +2117,7 @@ BOOLEAN FASTCALL co_UserDestroyWindow(PWINDOW_OBJECT Window) /* Look whether the focus is within the tree of windows we will * be destroying. */ - if (!co_WinPosShowWindow(Window->hSelf, SW_HIDE)) + if (!co_WinPosShowWindow(Window, SW_HIDE)) { if (UserGetActiveWindow() == Window->hSelf) { @@ -2862,7 +2866,7 @@ CLEANUP: HWND FASTCALL -UserSetParent(HWND hWndChild, HWND hWndNewParent) +co_UserSetParent(HWND hWndChild, HWND hWndNewParent) { PWINDOW_OBJECT Wnd = NULL, WndParent = NULL, WndOldParent; HWND hWndOldParent = NULL; @@ -2903,7 +2907,7 @@ UserSetParent(HWND hWndChild, HWND hWndNewParent) return( NULL); } - WndOldParent = IntSetParent(Wnd, WndParent); + WndOldParent = co_IntSetParent(Wnd, WndParent); if (WndOldParent) { @@ -2944,7 +2948,7 @@ NtUserSetParent(HWND hWndChild, HWND hWndNewParent) DPRINT("Enter NtUserSetParent\n"); UserEnterExclusive(); - RETURN( UserSetParent(hWndChild, hWndNewParent)); + RETURN( co_UserSetParent(hWndChild, hWndNewParent)); CLEANUP: DPRINT("Leave NtUserSetParent, ret=%i\n",_ret_); @@ -3408,7 +3412,7 @@ CLEANUP: LONG FASTCALL -UserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi) +co_UserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi) { PWINDOW_OBJECT Window, Parent; PWINSTATION_OBJECT WindowStation; @@ -3499,7 +3503,7 @@ UserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi) if (Parent && (Parent->hSelf == IntGetDesktopWindow())) OldValue = (LONG) IntSetOwner(Window->hSelf, (HWND) NewValue); else - OldValue = (LONG) UserSetParent(Window->hSelf, (HWND) NewValue); + OldValue = (LONG) co_UserSetParent(Window->hSelf, (HWND) NewValue); if(Parent) IntReleaseWindowObject(Parent); break; @@ -3548,7 +3552,7 @@ NtUserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi) DPRINT("Enter NtUserSetWindowLong\n"); UserEnterExclusive(); - RETURN( UserSetWindowLong(hWnd, Index, NewValue, Ansi)); + RETURN( co_UserSetWindowLong(hWnd, Index, NewValue, Ansi)); CLEANUP: DPRINT("Leave NtUserSetWindowLong, ret=%i\n",_ret_); @@ -3580,7 +3584,7 @@ NtUserSetWindowWord(HWND hWnd, INT Index, WORD NewValue) case GWL_ID: case GWL_HINSTANCE: case GWL_HWNDPARENT: - RETURN( UserSetWindowLong(hWnd, Index, (UINT)NewValue, TRUE)); + RETURN( co_UserSetWindowLong(hWnd, Index, (UINT)NewValue, TRUE)); default: if (Index < 0) { @@ -4064,7 +4068,7 @@ NtUserSetWindowPlacement(HWND hWnd, } /* FIXME - change window status */ - co_WinPosShowWindow(Window->hSelf, Safepl.showCmd); + co_WinPosShowWindow(Window, Safepl.showCmd); if (Window->InternalPos == NULL) Window->InternalPos = ExAllocatePoolWithTag(PagedPool, sizeof(INTERNALPOS), TAG_WININTLIST); @@ -4245,15 +4249,25 @@ CLEANUP: * @implemented */ BOOL STDCALL -NtUserShowWindow(HWND hWnd, - LONG nCmdShow) +NtUserShowWindow(HWND hWnd, LONG nCmdShow) { + PWINDOW_OBJECT Window; + BOOL ret; DECLARE_RETURN(BOOL); DPRINT("Enter NtUserShowWindow\n"); UserEnterExclusive(); - - RETURN( co_WinPosShowWindow(hWnd, nCmdShow)); + + if (!(Window = UserGetWindowObject(hWnd))) + { + RETURN(FALSE); + } + + UserReferenceWindowObjectCo(Window); + ret = co_WinPosShowWindow(Window, nCmdShow); + UserReferenceWindowObjectCo(Window); + + RETURN(ret); CLEANUP: DPRINT("Leave NtUserShowWindow, ret=%i\n",_ret_); diff --git a/reactos/subsys/win32k/ntuser/winpos.c b/reactos/subsys/win32k/ntuser/winpos.c index 2cb2fac3779..0a9635cd826 100644 --- a/reactos/subsys/win32k/ntuser/winpos.c +++ b/reactos/subsys/win32k/ntuser/winpos.c @@ -1236,25 +1236,15 @@ co_WinPosGetNonClientSize(HWND Wnd, RECT* WindowRect, RECT* ClientRect) } BOOLEAN FASTCALL -co_WinPosShowWindow(HWND Wnd, INT Cmd) +co_WinPosShowWindow(PWINDOW_OBJECT Window, INT Cmd) { BOOLEAN WasVisible; - PWINDOW_OBJECT Window; - NTSTATUS Status; UINT Swp = 0; RECT NewPos; BOOLEAN ShowFlag; // HRGN VisibleRgn; - Status = - ObmReferenceObjectByHandle(gHandleTable, - Wnd, - otWindow, - (PVOID*)&Window); - if (!NT_SUCCESS(Status)) - { - return(FALSE); - } + ASSERT_REFS(Window); WasVisible = (Window->Style & WS_VISIBLE) != 0; @@ -1264,7 +1254,6 @@ co_WinPosShowWindow(HWND Wnd, INT Cmd) { if (!WasVisible) { - ObmDereferenceObject(Window); return(FALSE); } Swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE; @@ -1336,14 +1325,14 @@ co_WinPosShowWindow(HWND Wnd, INT Cmd) ShowFlag = (Cmd != SW_HIDE); if (ShowFlag != WasVisible) { - co_IntSendMessage(Wnd, WM_SHOWWINDOW, ShowFlag, 0); + co_IntSendMessage(Window->hSelf, WM_SHOWWINDOW, ShowFlag, 0); /* * FIXME: Need to check the window wasn't destroyed during the * window procedure. */ if (!(Window->Parent)) { - co_IntShellHookNotify(HSHELL_WINDOWCREATED, (LPARAM)Wnd); + co_IntShellHookNotify(HSHELL_WINDOWCREATED, (LPARAM)Window->hSelf); } } @@ -1371,15 +1360,15 @@ co_WinPosShowWindow(HWND Wnd, INT Cmd) } /* Revert focus to parent */ - if (Wnd == IntGetThreadFocusWindow() || - IntIsChildWindow(Wnd, IntGetThreadFocusWindow())) + if (Window->hSelf == IntGetThreadFocusWindow() || + IntIsChildWindow(Window->hSelf, IntGetThreadFocusWindow())) { UserSetFocus(Window->Parent->hSelf); } if (!(Window->Parent)) { - co_IntShellHookNotify(HSHELL_WINDOWDESTROYED, (LPARAM)Wnd); + co_IntShellHookNotify(HSHELL_WINDOWDESTROYED, (LPARAM)Window->hSelf); } } @@ -1400,12 +1389,12 @@ co_WinPosShowWindow(HWND Wnd, INT Cmd) wParam = SIZE_MINIMIZED; } - co_IntSendMessage(Wnd, WM_SIZE, wParam, + co_IntSendMessage(Window->hSelf, WM_SIZE, wParam, MAKELONG(Window->ClientRect.right - Window->ClientRect.left, Window->ClientRect.bottom - Window->ClientRect.top)); - co_IntSendMessage(Wnd, WM_MOVE, 0, + co_IntSendMessage(Window->hSelf, WM_MOVE, 0, MAKELONG(Window->ClientRect.left, Window->ClientRect.top)); IntEngWindowChanged(Window, WOC_RGN_CLIENT); @@ -1418,8 +1407,6 @@ co_WinPosShowWindow(HWND Wnd, INT Cmd) WinPosChangeActiveWindow(Wnd, FALSE); } */ - - ObmDereferenceObject(Window); return(WasVisible); } @@ -1431,6 +1418,8 @@ co_WinPosSearchChildren( PWINDOW_OBJECT Current; HWND *List, *phWnd; + ASSERT_REFS(ScopeWin); + if ((List = IntWinListChildren(ScopeWin))) { for (phWnd = List; *phWnd; ++phWnd)