Author: weiden Date: Sat Nov 17 09:22:39 2007 New Revision: 30518
URL: http://svn.reactos.org/svn/reactos?rev=30518&view=rev Log: Optimize GetAncestor for the most common case GA_PARENT (for now)
Modified: trunk/reactos/dll/win32/user32/windows/window.c
Modified: trunk/reactos/dll/win32/user32/windows/window.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/wi... ============================================================================== --- trunk/reactos/dll/win32/user32/windows/window.c (original) +++ trunk/reactos/dll/win32/user32/windows/window.c Sat Nov 17 09:22:39 2007 @@ -842,7 +842,42 @@ HWND STDCALL GetAncestor(HWND hwnd, UINT gaFlags) { - return(NtUserGetAncestor(hwnd, gaFlags)); + HWND Ret = NULL; + PWINDOW Ancestor, Wnd; + + Wnd = ValidateHwnd(hwnd); + if (!Wnd) + return NULL; + + _SEH_TRY + { + Ancestor = NULL; + switch (gaFlags) + { + case GA_PARENT: + if (Wnd->Parent != NULL) + Ancestor = DesktopPtrToUser(Wnd->Parent); + break; + + default: + /* FIXME: Call win32k for now */ + Wnd = NULL; + break; + } + + if (Ancestor != NULL) + Ret = UserHMGetHandle(Ancestor); + } + _SEH_HANDLE + { + /* Do nothing */ + } + _SEH_END; + + if (!Wnd) /* Fall back */ + Ret = NtUserGetAncestor(hwnd, gaFlags); + + return Ret; }