From 2609d3aece2144fa601bab9dc25eab0ae5836e7b Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 28 Oct 2003 12:21:36 +0000 Subject: [PATCH] - Bugfixes of SetWindowPos. Now the window relinking really works for every window and not only for HWND_TOP. The Explorer Start Menu works now and desktop is painted. The dark side is that the desktop ShellView doesn't show anymore. svn path=/trunk/; revision=6444 --- reactos/subsys/win32k/ntuser/window.c | 7 +-- reactos/subsys/win32k/ntuser/winpos.c | 70 ++++++++++++++------------- 2 files changed, 40 insertions(+), 37 deletions(-) diff --git a/reactos/subsys/win32k/ntuser/window.c b/reactos/subsys/win32k/ntuser/window.c index 32ad07c3538..fc06ce3c3fc 100644 --- a/reactos/subsys/win32k/ntuser/window.c +++ b/reactos/subsys/win32k/ntuser/window.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: window.c,v 1.119 2003/10/25 22:57:34 navaraf Exp $ +/* $Id: window.c,v 1.120 2003/10/28 12:21:36 navaraf Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -2845,7 +2845,8 @@ NtUserSetShellWindowEx(HWND hwndShell, HWND hwndListView) return FALSE; /* move shell window into background */ - if (hwndListView && hwndListView!=hwndShell) { + if (hwndListView && hwndListView!=hwndShell) + { WinPosSetWindowPos(hwndListView, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE); if (NtUserGetWindowLong(hwndListView, GWL_EXSTYLE, FALSE) & WS_EX_TOPMOST) @@ -2853,7 +2854,7 @@ NtUserSetShellWindowEx(HWND hwndShell, HWND hwndListView) } if (NtUserGetWindowLong(hwndShell, GWL_EXSTYLE, FALSE) & WS_EX_TOPMOST) - return FALSE; + return FALSE; WinPosSetWindowPos(hwndShell, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE); diff --git a/reactos/subsys/win32k/ntuser/winpos.c b/reactos/subsys/win32k/ntuser/winpos.c index 93aa6887ccd..caa53b5d14e 100644 --- a/reactos/subsys/win32k/ntuser/winpos.c +++ b/reactos/subsys/win32k/ntuser/winpos.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: winpos.c,v 1.36 2003/10/23 09:07:54 gvg Exp $ +/* $Id: winpos.c,v 1.37 2003/10/28 12:21:36 navaraf Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -662,7 +662,7 @@ WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx, { flags |= SWP_NOMOVE; } - if (Window->Style & WIN_NCACTIVATED) + if (Window->Flags & WIN_NCACTIVATED) { flags |= SWP_NOACTIVATE; } @@ -682,7 +682,23 @@ WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx, if (WndInsertAfter != HWND_TOP && WndInsertAfter != HWND_BOTTOM) { - /* FIXME: Find the window to insert after. */ + if (NtUserGetAncestor(WndInsertAfter, GA_PARENT) != Window->Parent) + { + SetLastWin32Error(ERROR_INVALID_PARAMETER); + return FALSE; + } + else + { + /* + * Don't need to change the Zorder of hwnd if it's already inserted + * after hwndInsertAfter or when inserting hwnd after itself. + */ + if (Wnd == WndInsertAfter || + Wnd == NtUserGetWindow(WndInsertAfter, GW_HWNDNEXT)) + { + flags |= SWP_NOZORDER; + } + } } WinPos.hwnd = Wnd; @@ -701,9 +717,12 @@ WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx, WinPosDoWinPosChanging(Window, &WinPos, &NewWindowRect, &NewClientRect); if ((WinPos.flags & (SWP_NOZORDER | SWP_HIDEWINDOW | SWP_SHOWWINDOW)) != - SWP_NOZORDER) + SWP_NOZORDER && + NtUserGetAncestor(WinPos.hwnd, GA_PARENT) == + PsGetWin32Thread()->Desktop->DesktopWindow) { - /* FIXME: SWP_DoOwnedPopups. */ +/* FIXME */ +/* WinPos.hwndInsertAfter = WinPosDoOwnedPopups(WinPos.hwnd, WinPos.hwndInsertAfter);*/ } /* FIXME: Adjust flags based on WndInsertAfter */ @@ -737,46 +756,29 @@ WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx, /* * FIXME: Relink windows. (also take into account shell window in hwndShellWindow) */ - if (!(WinPos.flags & SWP_NOZORDER) && WinPos.hwndInsertAfter != WinPos.hwnd) + if (!(WinPos.flags & SWP_NOZORDER) && WinPos.hwndInsertAfter != WinPos.hwnd && + Window->Self != NtUserGetShellWindow()) { PWINDOW_OBJECT ParentWindow; PWINDOW_OBJECT InsertAfterWindow; ParentWindow = IntGetWindowObject(Window->ParentHandle); - if (WndInsertAfter == HWND_TOP) - { - InsertAfterWindow = NULL; - } - else if (WndInsertAfter != HWND_BOTTOM) - { - InsertAfterWindow = ParentWindow->LastChild; - } - else - { - InsertAfterWindow = IntGetWindowObject(WinPos.hwndInsertAfter); - } - - if (InsertAfterWindow != NULL && - InsertAfterWindow->ParentHandle != Window->ParentHandle) - { - ExAcquireFastMutexUnsafe(&ParentWindow->ChildrenListLock); - IntUnlinkWindow(Window); - ExReleaseFastMutexUnsafe(&ParentWindow->ChildrenListLock); - ParentWindow = IntGetWindowObject(InsertAfterWindow->ParentHandle); - ExAcquireFastMutexUnsafe(&ParentWindow->ChildrenListLock); - IntLinkWindow(Window, ParentWindow, InsertAfterWindow); - ExReleaseFastMutexUnsafe(&ParentWindow->ChildrenListLock); - } - else + if (ParentWindow) { + if (WndInsertAfter == HWND_TOP) + InsertAfterWindow = NULL; + else if (WndInsertAfter == HWND_BOTTOM) + InsertAfterWindow = ParentWindow->LastChild; + else + InsertAfterWindow = IntGetWindowObject(WinPos.hwndInsertAfter); ExAcquireFastMutexUnsafe(&ParentWindow->ChildrenListLock); IntUnlinkWindow(Window); IntLinkWindow(Window, ParentWindow, InsertAfterWindow); ExReleaseFastMutexUnsafe(&ParentWindow->ChildrenListLock); + IntReleaseWindowObject(ParentWindow); + if (InsertAfterWindow != NULL) + IntReleaseWindowObject(InsertAfterWindow); } - - IntReleaseWindowObject(ParentWindow); - IntReleaseWindowObject(InsertAfterWindow); } /* FIXME: Reset active DCEs */