Commit in reactos/subsys/win32k/ntuser on MAIN
winpos.c+26-71.106 -> 1.107
Fix interaction between topmost and owner/owned windows

reactos/subsys/win32k/ntuser
winpos.c 1.106 -> 1.107
diff -u -r1.106 -r1.107
--- winpos.c	30 Mar 2004 20:50:16 -0000	1.106
+++ winpos.c	1 Apr 2004 23:16:21 -0000	1.107
@@ -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.106 2004/03/30 20:50:16 gvg Exp $
+/* $Id: winpos.c,v 1.107 2004/04/01 23:16:21 gvg Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -612,15 +612,15 @@
    HWND *List = NULL;
    HWND Owner = NtUserGetWindow(hWnd, GW_OWNER);
    LONG Style = NtUserGetWindowLong(hWnd, GWL_STYLE, FALSE);
-   PWINDOW_OBJECT DesktopWindow;
+   PWINDOW_OBJECT DesktopWindow, ChildObject;
    int i;
 
    if ((Style & WS_POPUP) && Owner)
    {
       /* Make sure this popup stays above the owner */
-      HWND hWndLocalPrev = HWND_TOP;
+      HWND hWndLocalPrev = HWND_TOPMOST;
 
-      if (hWndInsertAfter != HWND_TOP)
+      if (hWndInsertAfter != HWND_TOPMOST)
       {
          DesktopWindow = IntGetWindowObject(IntGetDesktopWindow());
          List = IntWinListChildren(DesktopWindow);
@@ -630,6 +630,19 @@
             for (i = 0; List[i]; i++)
             {
                if (List[i] == Owner) break;
+               if (HWND_TOP == hWndInsertAfter)
+               {
+                 ChildObject = IntGetWindowObject(List[i]);
+                 if (NULL != ChildObject)
+                 {
+                   if (0 == (ChildObject->ExStyle & WS_EX_TOPMOST))
+                   {
+                     IntReleaseWindowObject(ChildObject);
+                     break;
+                   }
+                   IntReleaseWindowObject(ChildObject);
+                 }
+               }
                if (List[i] != hWnd) hWndLocalPrev = List[i];
                if (hWndLocalPrev == hWndInsertAfter) break;
             }
@@ -961,7 +974,12 @@
          }
          if (InsertAfterWindow != NULL)
             IntReleaseWindowObject(InsertAfterWindow);
-         if (HWND_TOPMOST == WinPos.hwndInsertAfter)
+         if ((HWND_TOPMOST == WinPos.hwndInsertAfter)
+             || (0 != (Window->ExStyle & WS_EX_TOPMOST)
+                 && NULL != Window->PrevSibling
+                 && 0 != (Window->PrevSibling->ExStyle & WS_EX_TOPMOST))
+             || (NULL != Window->NextSibling
+                 && 0 != (Window->NextSibling->ExStyle & WS_EX_TOPMOST)))
          {
             Window->ExStyle |= WS_EX_TOPMOST;
          }
@@ -1334,8 +1352,9 @@
       Swp |= SWP_NOACTIVATE | SWP_NOZORDER;
     }
 
-  WinPosSetWindowPos(Window->Self, HWND_TOP, NewPos.left, NewPos.top,
-    NewPos.right, NewPos.bottom, LOWORD(Swp));
+  WinPosSetWindowPos(Window->Self, 0 != (Window->ExStyle & WS_EX_TOPMOST)
+                                   ? HWND_TOPMOST : HWND_TOP,
+                     NewPos.left, NewPos.top, NewPos.right, NewPos.bottom, LOWORD(Swp));
 
   if (Cmd == SW_HIDE)
     {
CVSspam 0.2.8