From 80036846f55f6f6b789c56ea10e69dfe5d34014b Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Sat, 17 Nov 2007 07:19:47 +0000 Subject: [PATCH] Optimize GetWindow() for the case GW_OWNER to read from the desktop heap svn path=/trunk/; revision=30521 --- reactos/dll/win32/user32/windows/window.c | 37 ++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/reactos/dll/win32/user32/windows/window.c b/reactos/dll/win32/user32/windows/window.c index f26190c16e5..bab712cbb91 100644 --- a/reactos/dll/win32/user32/windows/window.c +++ b/reactos/dll/win32/user32/windows/window.c @@ -992,7 +992,42 @@ HWND STDCALL GetWindow(HWND hWnd, UINT uCmd) { - return NtUserGetWindow(hWnd, uCmd); + PWINDOW Wnd, FoundWnd; + HWND Ret = NULL; + + Wnd = ValidateHwnd(hWnd); + if (!Wnd) + return NULL; + + _SEH_TRY + { + FoundWnd = NULL; + switch (uCmd) + { + case GW_OWNER: + if (Wnd->Owner != NULL) + FoundWnd = DesktopPtrToUser(Wnd->Owner); + break; + + default: + /* FIXME: Optimize! Fall back to NtUserGetWindow for now... */ + Wnd = NULL; + break; + } + + if (FoundWnd != NULL) + Ret = UserHMGetHandle(FoundWnd); + } + _SEH_HANDLE + { + /* Do nothing */ + } + _SEH_END; + + if (!Wnd) /* Fall back to win32k... */ + Ret = NtUserGetWindow(hWnd, uCmd); + + return Ret; }