Commit in reactos/subsys/win32k/ntuser on MAIN
window.c+57-91.202 -> 1.203
winpos.c+43-81.105 -> 1.106
+100-17
2 modified files
Implement TOPMOST windows

reactos/subsys/win32k/ntuser
window.c 1.202 -> 1.203
diff -u -r1.202 -r1.203
--- window.c	28 Mar 2004 21:46:26 -0000	1.202
+++ window.c	30 Mar 2004 20:50:15 -0000	1.203
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: window.c,v 1.202 2004/03/28 21:46:26 weiden Exp $
+/* $Id: window.c,v 1.203 2004/03/30 20:50:15 gvg Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -873,7 +873,7 @@
 PWINDOW_OBJECT FASTCALL
 IntSetParent(PWINDOW_OBJECT Wnd, PWINDOW_OBJECT WndNewParent)
 {
-   PWINDOW_OBJECT WndOldParent;
+   PWINDOW_OBJECT WndOldParent, Sibling, InsertAfter;
    HWND hWnd, hWndNewParent, hWndOldParent;
    BOOL WasVisible;
    BOOL MenuChanged;
@@ -904,7 +904,29 @@
    if (WndNewParent != WndOldParent)
    {
       IntUnlinkWindow(Wnd);
-      IntLinkWindow(Wnd, WndNewParent, NULL /*prev sibling*/);
+      InsertAfter = NULL;
+      if (0 == (Wnd->ExStyle & WS_EX_TOPMOST))
+      {
+        /* Not a TOPMOST window, put after TOPMOSTs of new parent */
+        IntLockRelatives(WndNewParent);
+        Sibling = WndNewParent->FirstChild;
+        while (NULL != Sibling && 0 != (Sibling->ExStyle & WS_EX_TOPMOST))
+        {
+          InsertAfter = Sibling;
+          Sibling = Sibling->NextSibling;
+        }
+        IntUnLockRelatives(WndNewParent);
+      }
+      if (NULL == InsertAfter)
+      {
+        IntLinkWindow(Wnd, WndNewParent, InsertAfter /*prev sibling*/);
+      }
+      else
+      {
+        IntReferenceWindowObject(InsertAfter);
+        IntLinkWindow(Wnd, WndNewParent, InsertAfter /*prev sibling*/);
+        IntReleaseWindowObject(InsertAfter);
+      }
 
       if (WndNewParent->Self != IntGetDesktopWindow()) /* a child window */
       {
@@ -917,12 +939,13 @@
    }
    
    /*
-    * SetParent additionally needs to make hwnd the topmost window
-    * in the x-order and send the expected WM_WINDOWPOSCHANGING and
+    * SetParent additionally needs to make hwnd the top window
+    * in the z-order and send the expected WM_WINDOWPOSCHANGING and
     * WM_WINDOWPOSCHANGED notification messages.
     */
-   WinPosSetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0,
-      SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | (WasVisible ? SWP_SHOWWINDOW : 0));
+   WinPosSetWindowPos(hWnd, (0 == (Wnd->ExStyle & WS_EX_TOPMOST) ? HWND_TOP : HWND_TOPMOST),
+                      0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE
+                                | (WasVisible ? SWP_SHOWWINDOW : 0));
 
    /*
     * FIXME: a WM_MOVE is also generated (in the DefWindowProc handler
@@ -1613,8 +1636,33 @@
         }
       else
         {
-          /* link window as top sibling */
-          IntLinkWindow(WindowObject, ParentWindow, NULL /*prev sibling*/);
+          /* link window as top sibling (but after topmost siblings) */
+          PWINDOW_OBJECT InsertAfter, Sibling;
+          if (0 == (dwExStyle & WS_EX_TOPMOST))
+            {
+              IntLockRelatives(ParentWindow);
+              InsertAfter = NULL;
+              Sibling = ParentWindow->FirstChild;
+              while (NULL != Sibling && 0 != (Sibling->ExStyle & WS_EX_TOPMOST))
+                {
+                  InsertAfter = Sibling;
+                  Sibling = Sibling->NextSibling;
+                }
+              IntUnLockRelatives(ParentWindow);
+            }
+          else
+            {
+              InsertAfter = NULL;
+            }
+          if (NULL != InsertAfter)
+            {
+              IntReferenceWindowObject(InsertAfter);
+            }
+          IntLinkWindow(WindowObject, ParentWindow, InsertAfter /* prev sibling */);
+          if (NULL != InsertAfter)
+            {
+              IntReleaseWindowObject(InsertAfter);
+            }
         }
     }
 

reactos/subsys/win32k/ntuser
winpos.c 1.105 -> 1.106
diff -u -r1.105 -r1.106
--- winpos.c	23 Mar 2004 21:30:18 -0000	1.105
+++ winpos.c	30 Mar 2004 20:50:16 -0000	1.106
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: winpos.c,v 1.105 2004/03/23 21:30:18 gvg Exp $
+/* $Id: winpos.c,v 1.106 2004/03/30 20:50:16 gvg Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -745,7 +745,8 @@
       if (!(WinPos->flags & SWP_NOACTIVATE)) 
       {
          WinPos->flags &= ~SWP_NOZORDER;
-         WinPos->hwndInsertAfter = HWND_TOP;
+         WinPos->hwndInsertAfter = (0 != (Window->ExStyle & WS_EX_TOPMOST) ?
+                                    HWND_TOPMOST : HWND_TOP);
          return TRUE;
       }
    }
@@ -763,16 +764,22 @@
          WinPos->hwndInsertAfter = HWND_NOTOPMOST;
       }
 
-      /* FIXME: TOPMOST not supported yet */
-      if ((WinPos->hwndInsertAfter == HWND_TOPMOST) ||
-          (WinPos->hwndInsertAfter == HWND_NOTOPMOST))
+      if (WinPos->hwndInsertAfter == HWND_NOTOPMOST)
       {
          WinPos->hwndInsertAfter = HWND_TOP;
       }
+      else if (HWND_TOP == WinPos->hwndInsertAfter
+               && 0 != (Window->ExStyle & WS_EX_TOPMOST))
+      {
+         /* Keep it topmost when it's already topmost */
+         WinPos->hwndInsertAfter = HWND_TOPMOST;
+      }
 
       /* hwndInsertAfter must be a sibling of the window */
-      if ((WinPos->hwndInsertAfter != HWND_TOP) &&
-          (WinPos->hwndInsertAfter != HWND_BOTTOM))
+      if (HWND_TOPMOST != WinPos->hwndInsertAfter
+          && HWND_TOP != WinPos->hwndInsertAfter
+          && HWND_NOTOPMOST != WinPos->hwndInsertAfter
+          && HWND_BOTTOM != WinPos->hwndInsertAfter)
       {
          PWINDOW_OBJECT Parent = IntGetParentObject(Window);
          if (NtUserGetAncestor(WinPos->hwndInsertAfter, GA_PARENT) !=
@@ -905,12 +912,32 @@
    if (!(WinPos.flags & SWP_NOZORDER) && WinPos.hwnd != NtUserGetShellWindow())
    {
       PWINDOW_OBJECT ParentWindow;
+      PWINDOW_OBJECT Sibling;
       PWINDOW_OBJECT InsertAfterWindow;
 
       if ((ParentWindow = IntGetParentObject(Window)))
       {
-         if (WinPos.hwndInsertAfter == HWND_TOP)
+         if (HWND_TOPMOST == WinPos.hwndInsertAfter)
+         {
             InsertAfterWindow = NULL;
+         }
+         else if (HWND_TOP == WinPos.hwndInsertAfter
+                  || HWND_NOTOPMOST == WinPos.hwndInsertAfter)
+         {
+            InsertAfterWindow = NULL;
+            IntLockRelatives(ParentWindow);
+            Sibling = ParentWindow->FirstChild;
+            while (NULL != Sibling && 0 != (Sibling->ExStyle & WS_EX_TOPMOST))
+            {
+               InsertAfterWindow = Sibling;
+               Sibling = Sibling->NextSibling;
+            }
+            if (NULL != InsertAfterWindow)
+            {
+              IntReferenceWindowObject(InsertAfterWindow);
+            }
+            IntUnLockRelatives(ParentWindow);
+         }
          else if (WinPos.hwndInsertAfter == HWND_BOTTOM)
          {
             IntLockRelatives(ParentWindow);
@@ -934,6 +961,14 @@
          }
          if (InsertAfterWindow != NULL)
             IntReleaseWindowObject(InsertAfterWindow);
+         if (HWND_TOPMOST == WinPos.hwndInsertAfter)
+         {
+            Window->ExStyle |= WS_EX_TOPMOST;
+         }
+         else
+         {
+            Window->ExStyle &= ~ WS_EX_TOPMOST;
+         }
          
          IntReleaseWindowObject(ParentWindow);
       }
CVSspam 0.2.8