Please note my comment talked about NtUserGetCPD which must be used for some requests.
On 2009-12-13, at 3:01 PM, gadamopoulos(a)svn.reactos.org wrote:
Author: gadamopoulos
Date: Sun Dec 13 21:01:21 2009
New Revision: 44571
URL:
http://svn.reactos.org/svn/reactos?rev=44571&view=rev
Log:
[user32]
Optimize GetWindow by moving it completely to user mode
[win32k]
Remove reactos only syscall NtUserGetWindow
Modified:
trunk/reactos/dll/win32/user32/windows/window.c
trunk/reactos/include/reactos/win32k/ntuser.h
trunk/reactos/subsystems/win32/win32k/ntuser/window.c
trunk/reactos/subsystems/win32/win32k/w32ksvc.db
Modified: trunk/reactos/dll/win32/user32/windows/window.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/w…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/window.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/window.c [iso-8859-1] Sun Dec 13 21:01:21
2009
@@ -1024,8 +1024,36 @@
FoundWnd = DesktopPtrToUser(Wnd->spwndOwner);
break;
+ case GW_HWNDFIRST:
+ if(Wnd->spwndParent != NULL)
+ {
+ FoundWnd = DesktopPtrToUser(Wnd->spwndParent);
+ if (FoundWnd->spwndChild != NULL)
+ FoundWnd = DesktopPtrToUser(FoundWnd->spwndChild);
+ }
+ break;
+ case GW_HWNDNEXT:
+ if (Wnd->spwndNext != NULL)
+ FoundWnd = DesktopPtrToUser(Wnd->spwndNext);
+ break;
+
+ case GW_HWNDPREV:
+ if (Wnd->spwndPrev != NULL)
+ FoundWnd = DesktopPtrToUser(Wnd->spwndPrev);
+ break;
+
+ case GW_CHILD:
+ if (Wnd->spwndChild != NULL)
+ FoundWnd = DesktopPtrToUser(Wnd->spwndChild);
+ break;
+
+ case GW_HWNDLAST:
+ FoundWnd = Wnd;
+ while ( FoundWnd->spwndNext != NULL)
+ FoundWnd = DesktopPtrToUser(FoundWnd->spwndNext);
+ break;
+
default:
- /* FIXME: Optimize! Fall back to NtUserGetWindow for now... */
Wnd = NULL;
break;
}
@@ -1038,9 +1066,6 @@
/* Do nothing */
}
_SEH2_END;
-
- if (!Wnd) /* Fall back to win32k... */
- Ret = NtUserGetWindow(hWnd, uCmd);
return Ret;
}
Modified: trunk/reactos/include/reactos/win32k/ntuser.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/win32k/ntu…
==============================================================================
--- trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] Sun Dec 13 21:01:21 2009
@@ -3136,10 +3136,6 @@
int fnBar,
LPSCROLLINFO lpsi);
-HWND
-NTAPI
-NtUserGetWindow(HWND hWnd, UINT Relationship);
-
/* Should be done in usermode and use NtUserGetCPD. */
LONG
NTAPI
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/window.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] Sun Dec 13
21:01:21 2009
@@ -1014,6 +1014,31 @@
return FALSE;
}
+VOID FASTCALL
+IntLinkWnd(
+ PWND Wnd,
+ PWND WndParent,
+ PWND WndPrevSibling) /* set to NULL if top sibling */
+{
+ Wnd->spwndParent = WndParent;
+ if ((Wnd->spwndPrev = WndPrevSibling))
+ {
+ /* link after WndPrevSibling */
+ if ((Wnd->spwndNext = WndPrevSibling->spwndNext))
+ Wnd->spwndNext->spwndPrev = Wnd;
+
+ Wnd->spwndPrev->spwndNext = Wnd;
+ }
+ else
+ {
+ /* link at top */
+ if ((Wnd->spwndNext = WndParent->spwndChild))
+ Wnd->spwndNext->spwndPrev = Wnd;
+
+ WndParent->spwndChild = Wnd;
+ }
+
+}
/* link the window into siblings and parent. children are kept in place. */
VOID FASTCALL
@@ -1025,8 +1050,11 @@
{
PWINDOW_OBJECT Parent;
+ IntLinkWnd(Wnd->Wnd,
+ WndParent->Wnd,
+ WndPrevSibling ? WndPrevSibling->Wnd : NULL);
+
Wnd->Parent = WndParent;
- Wnd->Wnd->spwndParent = WndParent ? WndParent->Wnd : NULL;
if ((Wnd->PrevSibling = WndPrevSibling))
{
/* link after WndPrevSibling */
@@ -1221,12 +1249,30 @@
return TRUE;
}
+/* unlink the window from siblings and parent. children are kept in place. */
+VOID FASTCALL
+IntUnlinkWnd(PWND Wnd)
+{
+ if (Wnd->spwndNext)
+ Wnd->spwndNext->spwndPrev = Wnd->spwndPrev;
+
+ if (Wnd->spwndPrev)
+ Wnd->spwndPrev->spwndNext = Wnd->spwndNext;
+
+ if (Wnd->spwndParent && Wnd->spwndParent->spwndChild == Wnd)
+ Wnd->spwndParent->spwndChild = Wnd->spwndNext;
+
+ Wnd->spwndParent = Wnd->spwndPrev = Wnd->spwndNext = Wnd->spwndParent =
NULL;
+}
+
/* unlink the window from siblings and parent. children are kept in place. */
VOID FASTCALL
IntUnlinkWindow(PWINDOW_OBJECT Wnd)
{
PWINDOW_OBJECT WndParent = Wnd->Parent;
+
+ IntUnlinkWnd(Wnd->Wnd);
if (Wnd->NextSibling)
Wnd->NextSibling->PrevSibling = Wnd->PrevSibling;
@@ -1239,8 +1285,6 @@
WndParent->FirstChild = Wnd->NextSibling;
Wnd->PrevSibling = Wnd->NextSibling = Wnd->Parent = NULL;
- if (Wnd->Wnd)
- Wnd->Wnd->spwndParent = NULL;
}
BOOL FASTCALL
@@ -1915,6 +1959,11 @@
Window->LastChild = NULL;
Window->PrevSibling = NULL;
Window->NextSibling = NULL;
+
+ Wnd->spwndNext = NULL;
+ Wnd->spwndPrev = NULL;
+ Wnd->spwndChild = NULL;
+
Wnd->cbwndExtra = Wnd->pcls->cbwndExtra;
InitializeListHead(&Wnd->PropListHead);
@@ -3675,32 +3724,6 @@
}
return hWndResult;
-}
-
-/*
- * NtUserGetWindow
- *
- * The NtUserGetWindow function retrieves a handle to a window that has the
- * specified relationship (Z order or owner) to the specified window.
- *
- * Status
- * @implemented
- */
-
-HWND APIENTRY
-NtUserGetWindow(HWND hWnd, UINT Relationship)
-{
- DECLARE_RETURN(HWND);
-
- DPRINT("Enter NtUserGetWindow\n");
- UserEnterShared();
-
- RETURN(UserGetWindow(hWnd, Relationship));
-
-CLEANUP:
- DPRINT("Leave NtUserGetWindow, ret=%i\n",_ret_);
- UserLeave();
- END_CLEANUP;
}
/*
Modified: trunk/reactos/subsystems/win32/win32k/w32ksvc.db
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/w3…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/w32ksvc.db [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/w32ksvc.db [iso-8859-1] Sun Dec 13 21:01:21
2009
@@ -690,7 +690,6 @@
NtUserGetMinMaxInfo 3
NtUserGetMonitorInfo 2
NtUserGetScrollInfo 3
-NtUserGetWindow 2
NtUserGetWindowLong 3
NtUserMenuInfo 3
NtUserMenuItemInfo 5