Author: weiden
Date: Sat Nov 17 09:12:48 2007
New Revision: 30517
URL:
http://svn.reactos.org/svn/reactos?rev=30517&view=rev
Log:
Optimize GetParent() to read the information from the desktop heap
Modified:
trunk/reactos/dll/win32/user32/windows/class.c
trunk/reactos/dll/win32/user32/windows/window.c
trunk/reactos/include/reactos/win32k/ntuser.h
trunk/reactos/subsystems/win32/win32k/ntuser/callproc.c
trunk/reactos/subsystems/win32/win32k/ntuser/window.c
Modified: trunk/reactos/dll/win32/user32/windows/class.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/c…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/class.c (original)
+++ trunk/reactos/dll/win32/user32/windows/class.c Sat Nov 17 09:12:48 2007
@@ -527,6 +527,7 @@
return Wnd->UserData;
case GWL_HWNDPARENT:
+ DbgPrint("GWL_HWNDPARENT\n");
/* FIXME: Implement in user32 */
case GWL_WNDPROC:
/* Call win32k for this as a callproc handle may need
@@ -580,6 +581,7 @@
return Wnd->UserData;
case GWL_HWNDPARENT:
+ DbgPrint("GWL_HWNDPARENT\n");
/* FIXME: Implement in user32 */
case GWL_WNDPROC:
/* Call win32k for this as a callproc handle may need
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 (original)
+++ trunk/reactos/dll/win32/user32/windows/window.c Sat Nov 17 09:12:48 2007
@@ -893,7 +893,37 @@
HWND STDCALL
GetParent(HWND hWnd)
{
- return NtUserGetParent(hWnd);
+ PWINDOW Wnd, WndParent;
+ HWND Ret = NULL;
+
+ Wnd = ValidateHwnd(hWnd);
+ if (Wnd != NULL)
+ {
+ _SEH_TRY
+ {
+ WndParent = NULL;
+ if (Wnd->Style & WS_CHILD)
+ {
+ if (Wnd->Parent != NULL)
+ WndParent = DesktopPtrToUser(Wnd->Parent);
+ }
+ else if (Wnd->Style & WS_POPUP)
+ {
+ if (Wnd->Owner != NULL)
+ WndParent = DesktopPtrToUser(Wnd->Owner);
+ }
+
+ if (WndParent != NULL)
+ Ret = UserHMGetHandle(WndParent);
+ }
+ _SEH_HANDLE
+ {
+ /* Do nothing */
+ }
+ _SEH_END;
+ }
+
+ 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 (original)
+++ trunk/reactos/include/reactos/win32k/ntuser.h Sat Nov 17 09:12:48 2007
@@ -4,6 +4,9 @@
struct _W32PROCESSINFO;
struct _W32THREADINFO;
struct _WINDOW;
+
+/* FIXME: UserHMGetHandle needs to be updated once the new handle manager is implemented
*/
+#define UserHMGetHandle(obj) ((obj)->hdr.Handle)
typedef struct _REGISTER_SYSCLASS
{
@@ -19,6 +22,12 @@
UINT ClassId;
} REGISTER_SYSCLASS, *PREGISTER_SYSCLASS;
+typedef struct _USER_OBJHDR
+{
+ /* This is the common header for all user handle objects */
+ HANDLE Handle;
+} USER_OBJHDR, PUSER_OBJHDR;
+
typedef struct _DESKTOP
{
HANDLE hKernelHeap;
@@ -32,6 +41,7 @@
typedef struct _CALLPROC
{
+ USER_OBJHDR hdr; /* FIXME: Move out of the structure once new handle manager is
implemented */
struct _W32PROCESSINFO *pi;
WNDPROC WndProc;
struct _CALLPROC *Next;
@@ -92,6 +102,8 @@
typedef struct _WINDOW
{
+ USER_OBJHDR hdr; /* FIXME: Move out of the structure once new handle manager is
implemented */
+
/* NOTE: This structure is located in the desktop heap and will
eventually replace WINDOW_OBJECT. Right now WINDOW_OBJECT
keeps a reference to this structure until all the information
@@ -109,6 +121,9 @@
/* Extra Wnd proc (windows of system classes) */
WNDPROC WndProcExtra;
};
+
+ struct _WINDOW *Parent;
+ struct _WINDOW *Owner;
/* Size of the extra data associated with the window. */
ULONG ExtraDataSize;
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/callproc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/callproc.c (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/callproc.c Sat Nov 17 09:12:48 2007
@@ -67,6 +67,7 @@
sizeof(CALLPROC));
if (NewCallProc != NULL)
{
+ NewCallProc->hdr.Handle = Handle; /* FIXME: Remove hack */
NewCallProc->pi = CallProc->pi;
NewCallProc->WndProc = CallProc->WndProc;
NewCallProc->Unicode = CallProc->Unicode;
@@ -92,6 +93,7 @@
sizeof(CALLPROC));
if (NewCallProc != NULL)
{
+ NewCallProc->hdr.Handle = Handle; /* FIXME: Remove hack */
NewCallProc->pi = pi;
NewCallProc->WndProc = WndProc;
NewCallProc->Unicode = Unicode;
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 (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/window.c Sat Nov 17 09:12:48 2007
@@ -908,6 +908,7 @@
PWINDOW_OBJECT Parent;
Wnd->Parent = WndParent;
+ Wnd->Wnd->Parent = WndParent ? WndParent->Wnd : NULL;
if ((Wnd->PrevSibling = WndPrevSibling))
{
/* link after WndPrevSibling */
@@ -964,9 +965,13 @@
if((WndNewOwner = UserGetWindowObject(hWndNewOwner)))
{
Wnd->hOwner = hWndNewOwner;
+ Wnd->Wnd->Owner = WndNewOwner->Wnd;
}
else
+ {
Wnd->hOwner = NULL;
+ Wnd->Wnd->Owner = NULL;
+ }
UserDerefObject(Wnd);
return ret;
@@ -1109,6 +1114,7 @@
WndParent->FirstChild = Wnd->NextSibling;
Wnd->PrevSibling = Wnd->NextSibling = Wnd->Parent = NULL;
+ Wnd->Wnd->Parent = NULL;
}
BOOL FASTCALL
@@ -1575,10 +1581,11 @@
sizeof(WINDOW) + Class->WndExtra);
if (!Window->Wnd)
goto AllocErr;
- Wnd = Window->Wnd;
-
RtlZeroMemory(Window->Wnd,
sizeof(WINDOW) + Class->WndExtra);
+ Window->Wnd->hdr.Handle = hWnd; /* FIXME: Remove hack */
+ Wnd = Window->Wnd;
+
Wnd->ti = ti;
Wnd->pi = ti->kpi;
}
@@ -1631,15 +1638,18 @@
Window->MessageQueue = PsGetCurrentThreadWin32Thread()->MessageQueue;
IntReferenceMessageQueue(Window->MessageQueue);
Window->Parent = ParentWindow;
+ Wnd->Parent = ParentWindow ? ParentWindow->Wnd : NULL;
if((OwnerWindow = UserGetWindowObject(OwnerWindowHandle)))
{
Window->hOwner = OwnerWindowHandle;
+ Wnd->Owner = OwnerWindow->Wnd;
HasOwner = TRUE;
}
else
{
Window->hOwner = NULL;
+ Wnd->Owner = NULL;
HasOwner = FALSE;
}
@@ -2336,6 +2346,7 @@
if (Child->hOwner != NULL)
{
Child->hOwner = NULL;
+ Child->Wnd->Owner = NULL;
}
}