[ros-diffs] [weiden] 30610: Store the internal window placement directly inside the WINDOW structure

weiden at svn.reactos.org weiden at svn.reactos.org
Wed Nov 21 06:35:33 CET 2007


Author: weiden
Date: Wed Nov 21 08:35:33 2007
New Revision: 30610

URL: http://svn.reactos.org/svn/reactos?rev=30610&view=rev
Log:
Store the internal window placement directly inside the WINDOW structure

Modified:
    trunk/reactos/dll/win32/user32/windows/window.c
    trunk/reactos/include/reactos/win32k/ntuser.h
    trunk/reactos/subsystems/win32/win32k/include/window.h
    trunk/reactos/subsystems/win32/win32k/include/winpos.h
    trunk/reactos/subsystems/win32/win32k/ntuser/misc.c
    trunk/reactos/subsystems/win32/win32k/ntuser/window.c
    trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c

Modified: trunk/reactos/dll/win32/user32/windows/window.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/window.c?rev=30610&r1=30609&r2=30610&view=diff
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/window.c (original)
+++ trunk/reactos/dll/win32/user32/windows/window.c Wed Nov 21 08:35:33 2007
@@ -1854,7 +1854,13 @@
 STDCALL
 GetWindowContextHelpId(HWND hwnd)
 {
-  return NtUserGetWindowContextHelpId(hwnd);
+    PWINDOW Wnd = ValidateHwnd(hwnd);
+    if (Wnd != NULL)
+    {
+        return Wnd->ContextHelpId;
+    }
+
+    return 0;
 }
 
 /*

Modified: trunk/reactos/include/reactos/win32k/ntuser.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/win32k/ntuser.h?rev=30610&r1=30609&r2=30610&view=diff
==============================================================================
--- trunk/reactos/include/reactos/win32k/ntuser.h (original)
+++ trunk/reactos/include/reactos/win32k/ntuser.h Wed Nov 21 08:35:33 2007
@@ -140,10 +140,20 @@
     PWINDOWCLASS Class;
     /* Window name. */
     UNICODE_STRING WindowName;
+    /* Context help id */
+    DWORD ContextHelpId;
+
+    struct
+    {
+        RECT NormalRect;
+        POINT IconPos;
+        POINT MaxPos;
+    } InternalPos;
 
     UINT Unicode : 1;
     /* Indicates whether the window is derived from a system class */
     UINT IsSystem : 1;
+    UINT InternalPosInitialized : 1;
 } WINDOW, *PWINDOW;
 
 typedef struct _W32PROCESSINFO

Modified: trunk/reactos/subsystems/win32/win32k/include/window.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/include/window.h?rev=30610&r1=30609&r2=30610&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/window.h (original)
+++ trunk/reactos/subsystems/win32/win32k/include/window.h Wed Nov 21 08:35:33 2007
@@ -13,17 +13,6 @@
 #include <include/prop.h>
 #include <include/scroll.h>
 
-
-VOID FASTCALL
-WinPosSetupInternalPos(VOID);
-
-typedef struct _INTERNALPOS
-{
-  RECT NormalRect;
-  POINT IconPos;
-  POINT MaxPos;
-} INTERNALPOS, *PINTERNALPOS;
-
 typedef struct _WINDOW_OBJECT
 {
   /* NOTE: Do *NOT* Move this pointer anywhere in this structure! This
@@ -36,8 +25,6 @@
   PW32THREADINFO ti;
   /* Pointer to the desktop */
   PDESKTOP Desktop;
-  /* Context help id */
-  DWORD ContextHelpId;
   /* system menu handle. */
   HMENU SystemMenu;
   /* Entry in the thread's list of windows. */
@@ -71,7 +58,6 @@
   PWINDOW_SCROLLINFO Scroll;
   PETHREAD OwnerThread;
   HWND hWndLastPopup; /* handle to last active popup window (wine doesn't use pointer, for unk. reason)*/
-  PINTERNALPOS InternalPos;
   ULONG Status;
   /* counter for tiled child windows */
   ULONG TiledCounter;

Modified: trunk/reactos/subsystems/win32/win32k/include/winpos.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/include/winpos.h?rev=30610&r1=30609&r2=30610&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/winpos.h (original)
+++ trunk/reactos/subsystems/win32/win32k/include/winpos.h Wed Nov 21 08:35:33 2007
@@ -35,7 +35,7 @@
 		      PWINDOW_OBJECT* Window);
 VOID FASTCALL co_WinPosActivateOtherWindow(PWINDOW_OBJECT Window);
 
-PINTERNALPOS FASTCALL WinPosInitInternalPos(PWINDOW_OBJECT WindowObject,
-                                            POINT *pt, PRECT RestoreRect);
+VOID FASTCALL WinPosInitInternalPos(PWINDOW_OBJECT WindowObject,
+                                    POINT *pt, PRECT RestoreRect);
 
 #endif /* _WIN32K_WINPOS_H */

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/misc.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/misc.c?rev=30610&r1=30609&r2=30610&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/misc.c (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/misc.c Wed Nov 21 08:35:33 2007
@@ -301,7 +301,7 @@
                RETURN( FALSE);
             }
 
-            Result = Window->ContextHelpId;
+            Result = Window->Wnd->ContextHelpId;
 
             RETURN( Result);
          }
@@ -605,7 +605,7 @@
             RETURN( (DWORD)FALSE);
          }
 
-         Window->ContextHelpId = Param2;
+         Window->Wnd->ContextHelpId = Param2;
 
          RETURN( (DWORD)TRUE);
 

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/window.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/window.c?rev=30610&r1=30609&r2=30610&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/window.c (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/window.c Wed Nov 21 08:35:33 2007
@@ -1618,7 +1618,7 @@
    Class = NULL;
 
    Window->SystemMenu = (HMENU)0;
-   Window->ContextHelpId = 0;
+   Wnd->ContextHelpId = 0;
    Wnd->IDMenu = 0;
    Wnd->Instance = hInstance;
    Window->hSelf = hWnd;
@@ -3883,7 +3883,6 @@
 {
    PWINDOW_OBJECT Window;
    PWINDOW Wnd;
-   PINTERNALPOS InternalPos;
    POINT Size;
    WINDOWPLACEMENT Safepl;
    NTSTATUS Status;
@@ -3930,18 +3929,12 @@
 
    Size.x = Wnd->WindowRect.left;
    Size.y = Wnd->WindowRect.top;
-   InternalPos = WinPosInitInternalPos(Window, &Size,
-                                       &Wnd->WindowRect);
-   if (InternalPos)
-   {
-      Safepl.rcNormalPosition = InternalPos->NormalRect;
-      Safepl.ptMinPosition = InternalPos->IconPos;
-      Safepl.ptMaxPosition = InternalPos->MaxPos;
-   }
-   else
-   {
-      RETURN( FALSE);
-   }
+   WinPosInitInternalPos(Window, &Size,
+                         &Wnd->WindowRect);
+
+   Safepl.rcNormalPosition = Wnd->InternalPos.NormalRect;
+   Safepl.ptMinPosition = Wnd->InternalPos.IconPos;
+   Safepl.ptMaxPosition = Wnd->InternalPos.MaxPos;
 
    Status = MmCopyToCaller(lpwndpl, &Safepl, sizeof(WINDOWPLACEMENT));
    if(!NT_SUCCESS(Status))
@@ -4334,11 +4327,10 @@
    /* FIXME - change window status */
    co_WinPosShowWindow(Window, Safepl.showCmd);
 
-   if (Window->InternalPos == NULL)
-      Window->InternalPos = ExAllocatePoolWithTag(PagedPool, sizeof(INTERNALPOS), TAG_WININTLIST);
-   Window->InternalPos->NormalRect = Safepl.rcNormalPosition;
-   Window->InternalPos->IconPos = Safepl.ptMinPosition;
-   Window->InternalPos->MaxPos = Safepl.ptMaxPosition;
+   Wnd->InternalPosInitialized = TRUE;
+   Wnd->InternalPos.NormalRect = Safepl.rcNormalPosition;
+   Wnd->InternalPos.IconPos = Safepl.ptMinPosition;
+   Wnd->InternalPos.MaxPos = Safepl.ptMaxPosition;
 
    UserDerefObjectCo(Window);
    RETURN(TRUE);

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c?rev=30610&r1=30609&r2=30610&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c Wed Nov 21 08:35:33 2007
@@ -267,14 +267,14 @@
    /* FIXME */
 }
 
-PINTERNALPOS FASTCALL
+VOID FASTCALL
 WinPosInitInternalPos(PWINDOW_OBJECT Window, POINT *pt, PRECT RestoreRect)
 {
-   PWINDOW_OBJECT Parent;
-   UINT XInc, YInc;
-   PWINDOW Wnd = Window->Wnd;
-
-   if (Window->InternalPos == NULL)
+    PWINDOW_OBJECT Parent;
+    UINT XInc, YInc;
+    PWINDOW Wnd = Window->Wnd;
+
+   if (!Wnd->InternalPosInitialized)
    {
       RECT WorkArea;
       PDESKTOP_OBJECT Desktop = PsGetCurrentThreadWin32Thread()->Desktop; /* Or rather get it from the window? */
@@ -290,51 +290,43 @@
       else
          IntGetDesktopWorkArea(Desktop, &WorkArea);
 
-      Window->InternalPos = ExAllocatePoolWithTag(PagedPool, sizeof(INTERNALPOS), TAG_WININTLIST);
-      if(!Window->InternalPos)
-      {
-         DPRINT1("Failed to allocate INTERNALPOS structure for window 0x%x\n", Window->hSelf);
-         return NULL;
-      }
-      Window->InternalPos->NormalRect = Window->Wnd->WindowRect;
+      Wnd->InternalPos.NormalRect = Window->Wnd->WindowRect;
       IntGetWindowBorderMeasures(Window, &XInc, &YInc);
-      Window->InternalPos->MaxPos.x = WorkArea.left - XInc;
-      Window->InternalPos->MaxPos.y = WorkArea.top - YInc;
-      Window->InternalPos->IconPos.x = WorkArea.left;
-      Window->InternalPos->IconPos.y = WorkArea.bottom - UserGetSystemMetrics(SM_CYMINIMIZED);
+      Wnd->InternalPos.MaxPos.x = WorkArea.left - XInc;
+      Wnd->InternalPos.MaxPos.y = WorkArea.top - YInc;
+      Wnd->InternalPos.IconPos.x = WorkArea.left;
+      Wnd->InternalPos.IconPos.y = WorkArea.bottom - UserGetSystemMetrics(SM_CYMINIMIZED);
+
+      Wnd->InternalPosInitialized = TRUE;
    }
    if (Wnd->Style & WS_MINIMIZE)
    {
-      Window->InternalPos->IconPos = *pt;
+      Wnd->InternalPos.IconPos = *pt;
    }
    else if (Wnd->Style & WS_MAXIMIZE)
    {
-      Window->InternalPos->MaxPos = *pt;
+      Wnd->InternalPos.MaxPos = *pt;
    }
    else if (RestoreRect != NULL)
    {
-      Window->InternalPos->NormalRect = *RestoreRect;
-   }
-   return(Window->InternalPos);
+      Wnd->InternalPos.NormalRect = *RestoreRect;
+   }
 }
 
 UINT FASTCALL
 co_WinPosMinMaximize(PWINDOW_OBJECT Window, UINT ShowFlag, RECT* NewPos)
 {
    POINT Size;
-   PINTERNALPOS InternalPos;
    UINT SwpFlags = 0;
    PWINDOW Wnd;
 
    ASSERT_REFS_CO(Window);
    Wnd = Window->Wnd;
 
-   Size.x = Window->Wnd->WindowRect.left;
-   Size.y = Window->Wnd->WindowRect.top;
-   InternalPos = WinPosInitInternalPos(Window, &Size, &Window->Wnd->WindowRect);
-
-   if (InternalPos)
-   {
+   Size.x = Wnd->WindowRect.left;
+   Size.y = Wnd->WindowRect.top;
+   WinPosInitInternalPos(Window, &Size, &Wnd->WindowRect);
+
       if (Wnd->Style & WS_MINIMIZE)
       {
          if (!co_IntSendMessage(Window->hSelf, WM_QUERYOPEN, 0, 0))
@@ -359,8 +351,8 @@
                co_UserRedrawWindow(Window, NULL, 0, RDW_VALIDATE | RDW_NOERASE |
                                    RDW_NOINTERNALPAINT);
                Wnd->Style |= WS_MINIMIZE;
-               WinPosFindIconPos(Window, &InternalPos->IconPos);
-               IntGdiSetRect(NewPos, InternalPos->IconPos.x, InternalPos->IconPos.y,
+               WinPosFindIconPos(Window, &Wnd->InternalPos.IconPos);
+               IntGdiSetRect(NewPos, Wnd->InternalPos.IconPos.x, Wnd->InternalPos.IconPos.y,
                              UserGetSystemMetrics(SM_CXMINIMIZED),
                              UserGetSystemMetrics(SM_CYMINIMIZED));
                SwpFlags |= SWP_NOCOPYBITS;
@@ -369,16 +361,16 @@
 
          case SW_MAXIMIZE:
             {
-               co_WinPosGetMinMaxInfo(Window, &Size, &InternalPos->MaxPos,
+               co_WinPosGetMinMaxInfo(Window, &Size, &Wnd->InternalPos.MaxPos,
                                       NULL, NULL);
                DPRINT("Maximize: %d,%d %dx%d\n",
-                      InternalPos->MaxPos.x, InternalPos->MaxPos.y, Size.x, Size.y);
+                      Wnd->InternalPos.MaxPos.x, Wnd->InternalPos.MaxPos.y, Size.x, Size.y);
                if (Wnd->Style & WS_MINIMIZE)
                {
                   Wnd->Style &= ~WS_MINIMIZE;
                }
                Wnd->Style |= WS_MAXIMIZE;
-               IntGdiSetRect(NewPos, InternalPos->MaxPos.x, InternalPos->MaxPos.y,
+               IntGdiSetRect(NewPos, Wnd->InternalPos.MaxPos.x, Wnd->InternalPos.MaxPos.y,
                              Size.x, Size.y);
                break;
             }
@@ -391,15 +383,15 @@
                   if (Window->Flags & WINDOWOBJECT_RESTOREMAX)
                   {
                      co_WinPosGetMinMaxInfo(Window, &Size,
-                                            &InternalPos->MaxPos, NULL, NULL);
+                                            &Wnd->InternalPos.MaxPos, NULL, NULL);
                      Wnd->Style |= WS_MAXIMIZE;
-                     IntGdiSetRect(NewPos, InternalPos->MaxPos.x,
-                                   InternalPos->MaxPos.y, Size.x, Size.y);
+                     IntGdiSetRect(NewPos, Wnd->InternalPos.MaxPos.x,
+                                   Wnd->InternalPos.MaxPos.y, Size.x, Size.y);
                      break;
                   }
                   else
                   {
-                     *NewPos = InternalPos->NormalRect;
+                     *NewPos = Wnd->InternalPos.NormalRect;
                      NewPos->right -= NewPos->left;
                      NewPos->bottom -= NewPos->top;
                      break;
@@ -412,18 +404,14 @@
                      return 0;
                   }
                   Wnd->Style &= ~WS_MAXIMIZE;
-                  *NewPos = InternalPos->NormalRect;
+                  *NewPos = Wnd->InternalPos.NormalRect;
                   NewPos->right -= NewPos->left;
                   NewPos->bottom -= NewPos->top;
                   break;
                }
             }
       }
-   }
-   else
-   {
-      SwpFlags |= SWP_NOSIZE | SWP_NOMOVE;
-   }
+
    return(SwpFlags);
 }
 
@@ -447,9 +435,9 @@
    Info->ptMaxTrackSize.x = Info->ptMaxSize.x;
    Info->ptMaxTrackSize.y = Info->ptMaxSize.y;
 
-   if (Window->InternalPos != NULL)
-   {
-      Info->ptMaxPosition = Window->InternalPos->MaxPos;
+   if (Window->Wnd->InternalPosInitialized)
+   {
+      Info->ptMaxPosition = Window->Wnd->InternalPos.MaxPos;
    }
    else
    {
@@ -1696,8 +1684,8 @@
    BOOL SendMessage)
 {
    POINT Size;
-   PINTERNALPOS InternalPos;
    PWINDOW_OBJECT Window = NULL;
+   PWINDOW Wnd;
    MINMAXINFO SafeMinMax;
    NTSTATUS Status;
    DECLARE_RETURN(BOOL);
@@ -1712,33 +1700,30 @@
    }
 
    UserRefObjectCo(Window, &Ref);
+   Wnd = Window->Wnd;
 
    Size.x = Window->Wnd->WindowRect.left;
    Size.y = Window->Wnd->WindowRect.top;
-   InternalPos = WinPosInitInternalPos(Window, &Size,
-                                       &Window->Wnd->WindowRect);
-   if(InternalPos)
-   {
-      if(SendMessage)
-      {
-         co_WinPosGetMinMaxInfo(Window, &SafeMinMax.ptMaxSize, &SafeMinMax.ptMaxPosition,
-                                &SafeMinMax.ptMinTrackSize, &SafeMinMax.ptMaxTrackSize);
-      }
-      else
-      {
-         WinPosFillMinMaxInfoStruct(Window, &SafeMinMax);
-      }
-      Status = MmCopyToCaller(MinMaxInfo, &SafeMinMax, sizeof(MINMAXINFO));
-      if(!NT_SUCCESS(Status))
-      {
-         SetLastNtError(Status);
-         RETURN( FALSE);
-      }
-
-      RETURN( TRUE);
-   }
-
-   RETURN( FALSE);
+   WinPosInitInternalPos(Window, &Size,
+                         &Wnd->WindowRect);
+
+   if(SendMessage)
+   {
+      co_WinPosGetMinMaxInfo(Window, &SafeMinMax.ptMaxSize, &SafeMinMax.ptMaxPosition,
+                             &SafeMinMax.ptMinTrackSize, &SafeMinMax.ptMaxTrackSize);
+   }
+   else
+   {
+      WinPosFillMinMaxInfoStruct(Window, &SafeMinMax);
+   }
+   Status = MmCopyToCaller(MinMaxInfo, &SafeMinMax, sizeof(MINMAXINFO));
+   if(!NT_SUCCESS(Status))
+   {
+      SetLastNtError(Status);
+      RETURN( FALSE);
+   }
+
+   RETURN( TRUE);
 
 CLEANUP:
    if (Window) UserDerefObjectCo(Window);




More information about the Ros-diffs mailing list