[Win32ss]
authorJames Tabor <james.tabor@reactos.org>
Thu, 22 Jan 2015 23:31:22 +0000 (23:31 +0000)
committerJames Tabor <james.tabor@reactos.org>
Thu, 22 Jan 2015 23:31:22 +0000 (23:31 +0000)
- Plugging in the real fix for CORE-6129!
- Works like it should, but CMD properties window gets active when it should not. See CORE-6651.

svn path=/trunk/; revision=66078

reactos/win32ss/user/ntuser/defwnd.c
reactos/win32ss/user/ntuser/msgqueue.c
reactos/win32ss/user/ntuser/winpos.c
reactos/win32ss/user/ntuser/winpos.h

index c8d38d8..dc6035c 100644 (file)
@@ -754,6 +754,29 @@ DefWndHandleSysCommand(PWND pWnd, WPARAM wParam, LPARAM lParam)
    return(Hook ? 1 : 0); // Don't call us again from user space.
 }
 
+#if 0 // Keep it for later!
+PWND FASTCALL
+co_IntFindChildWindowToOwner(PWND Root, PWND Owner)
+{
+   PWND Ret;
+   PWND Child, OwnerWnd;
+
+   for(Child = Root->spwndChild; Child; Child = Child->spwndNext)
+   {
+      OwnerWnd = Child->spwndOwner;
+      if(!OwnerWnd)
+         continue;
+
+      if(OwnerWnd == Owner)
+      {
+         Ret = Child;
+         return Ret;
+      }
+   }
+   return NULL;
+}
+#endif
+
 VOID FASTCALL DefWndPrint( PWND pwnd, HDC hdc, ULONG uFlags)
 {
   /*
index 4a167ee..03a56b7 100644 (file)
@@ -1466,27 +1466,6 @@ IntTrackMouseMove(PWND pwndTrack, PDESKTOP pDesk, PMSG msg, USHORT hittest)
    }
 }
 
-PWND FASTCALL
-co_IntFindChildWindowToOwner(PWND Root, PWND Owner)
-{
-   PWND Ret;
-   PWND Child, OwnerWnd;
-
-   for(Child = Root->spwndChild; Child; Child = Child->spwndNext)
-   {
-      OwnerWnd = Child->spwndOwner;
-      if(!OwnerWnd)
-         continue;
-
-      if(OwnerWnd == Owner)
-      {
-         Ret = Child;
-         return Ret;
-      }
-   }
-   return NULL;
-}
-
 BOOL co_IntProcessMouseMessage(MSG* msg, BOOL* RemoveMessages, UINT first, UINT last)
 {
     MSG clk_msg;
@@ -1497,7 +1476,7 @@ BOOL co_IntProcessMouseMessage(MSG* msg, BOOL* RemoveMessages, UINT first, UINT
     MOUSEHOOKSTRUCT hook;
     BOOL eatMsg = FALSE;
 
-    PWND pwndMsg, pwndDesktop, pwndPopUP;
+    PWND pwndMsg, pwndDesktop, pwndOrig;
     PUSER_MESSAGE_QUEUE MessageQueue;
     PTHREADINFO pti;
     PSYSTEM_CURSORINFO CurInfo;
@@ -1508,7 +1487,7 @@ BOOL co_IntProcessMouseMessage(MSG* msg, BOOL* RemoveMessages, UINT first, UINT
     pwndDesktop = UserGetDesktopWindow();
     MessageQueue = pti->MessageQueue;
     CurInfo = IntGetSysCursorInfo();
-    pwndPopUP = pwndMsg = ValidateHwndNoErr(msg->hwnd);
+    pwndOrig = pwndMsg = ValidateHwndNoErr(msg->hwnd);
     clk_msg = MessageQueue->msgDblClk;
     pDesk = pwndDesktop->head.rpdesk;
 
@@ -1526,23 +1505,14 @@ BOOL co_IntProcessMouseMessage(MSG* msg, BOOL* RemoveMessages, UINT first, UINT
         */
         pwndMsg = co_WinPosWindowFromPoint( NULL, &msg->pt, &hittest, FALSE);
         //
-        // CORE-6129, Override if a diabled window with a visible popup was selected.
+        // CORE-6129, Override if a diabled window, it might have a visible popup.
         //
-        if (pwndPopUP && pwndPopUP->style & WS_DISABLED)
+        if ( pwndOrig && pwndOrig->style & WS_DISABLED )
         {
-           TRACE("window disabled\n");
-           pwndPopUP = co_IntFindChildWindowToOwner(UserGetDesktopWindow(), pwndPopUP);
-           if ( pwndPopUP &&
-                pwndPopUP->style & WS_POPUP &&
-                pwndPopUP->style & WS_VISIBLE &&
-                (pwndPopUP->head.pti->MessageQueue != gpqForeground ||
-                 pwndPopUP->head.pti->MessageQueue->spwndActive != pwndPopUP) &&
-              //pwndPopUP != pwndPopUP->head.rpdesk->pDeskInfo->spwndShell needs testing.
-                pwndPopUP != ValidateHwndNoErr(InputWindowStation->ShellWindow) )
+           if ( hittest == (USHORT)HTERROR )
            {
-               TRACE("Found Popup!\n");
-               UserDereferenceObject(pwndMsg);
-               pwndMsg = pwndPopUP;
+               if (pwndMsg) UserReferenceObject(pwndMsg);
+               pwndMsg = pwndOrig;
                UserReferenceObject(pwndMsg);
            }
         }
@@ -1571,6 +1541,7 @@ BOOL co_IntProcessMouseMessage(MSG* msg, BOOL* RemoveMessages, UINT first, UINT
 
     pt = msg->pt;
     message = msg->message;
+
     /* Note: windows has no concept of a non-client wheel message */
     if (message != WM_MOUSEWHEEL)
     {
@@ -1711,11 +1682,10 @@ BOOL co_IntProcessMouseMessage(MSG* msg, BOOL* RemoveMessages, UINT first, UINT
         RETURN(FALSE);
     }
 
-    if ((hittest == HTERROR) || (hittest == HTNOWHERE))
+    if ((hittest == (USHORT)HTERROR) || (hittest == (USHORT)HTNOWHERE))
     {
-        co_IntSendMessage( msg->hwnd, WM_SETCURSOR, (WPARAM)msg->hwnd,
-                      MAKELONG( hittest, msg->message ));
-
+        co_IntSendMessage( msg->hwnd, WM_SETCURSOR, (WPARAM)msg->hwnd, MAKELONG( hittest, msg->message ));
+        ERR("HT errors!\n");
         /* Remove and skip message */
         *RemoveMessages = TRUE;
         RETURN(FALSE);
@@ -1746,6 +1716,8 @@ BOOL co_IntProcessMouseMessage(MSG* msg, BOOL* RemoveMessages, UINT first, UINT
             PWND pwndTop = pwndMsg;
             pwndTop = IntGetNonChildAncestor(pwndTop);
 
+            TRACE("Mouse pti %p pwndMsg pti %p pwndTop pti %p\n",MessageQueue->ptiMouse,pwndMsg->head.pti,pwndTop->head.pti);
+
             if (pwndTop && pwndTop != pwndDesktop)
             {
                 LONG ret = co_IntSendMessage( msg->hwnd,
index a436f5d..f2a0b8d 100644 (file)
@@ -349,7 +349,6 @@ co_WinPosActivateOtherWindow(PWND Wnd)
    {
       WndTo = Wnd->head.pti->MessageQueue->spwndActivePrev;
       if (can_activate_window( WndTo )) goto done;
-      
    }
 
    // Find any window to bring to top. Works Okay for wine since it does not see X11 windows.
@@ -2410,13 +2409,12 @@ co_WinPosShowWindow(PWND Wnd, INT Cmd)
    return(WasVisible);
 }
 
-static
-PWND FASTCALL
+static PWND
 co_WinPosSearchChildren(
-   PWND ScopeWin,
-   POINT *Point,
-   USHORT *HitTest,
-   BOOL Ignore
+   IN PWND ScopeWin,
+   IN POINT *Point,
+   IN OUT USHORT *HitTest,
+   IN BOOL Ignore
    )
 {
     PWND pwndChild;
@@ -2429,6 +2427,7 @@ co_WinPosSearchChildren(
 
     if (!Ignore && (ScopeWin->style & WS_DISABLED))
     {
+        *HitTest = HTERROR;
         return NULL;
     }
 
@@ -2467,8 +2466,8 @@ co_WinPosSearchChildren(
 
     if (ScopeWin->head.pti == PsGetCurrentThreadWin32Thread())
     {
-       *HitTest = (USHORT)co_IntSendMessage(ScopeWin->head.h, WM_NCHITTEST, 0,
-                                            MAKELONG(Point->x, Point->y));
+       *HitTest = (USHORT)co_IntSendMessage(ScopeWin->head.h, WM_NCHITTEST, 0, MAKELONG(Point->x, Point->y));
+
        if ((*HitTest) == (USHORT)HTTRANSPARENT)
        {
            UserDereferenceObject(ScopeWin);
@@ -2476,13 +2475,15 @@ co_WinPosSearchChildren(
        }
     }
     else
-       *HitTest = HTCLIENT;
+    {
+       if (*HitTest == HTNOWHERE && pwndChild == NULL) *HitTest = HTCLIENT;
+    }
 
     return ScopeWin;
 }
 
-PWND FASTCALL
-co_WinPosWindowFromPoint(PWND ScopeWin, POINT *WinPoint, USHORT* HitTest, BOOL Ignore)
+PWND APIENTRY
+co_WinPosWindowFromPoint(IN PWND ScopeWin, IN POINT *WinPoint, IN OUT USHORT* HitTest, IN BOOL Ignore)
 {
    PWND Window;
    POINT Point = *WinPoint;
index ed3464c..fde65df 100644 (file)
@@ -52,7 +52,7 @@ UINT FASTCALL co_WinPosMinMaximize(PWND WindowObject, UINT ShowFlag, RECTL* NewP
 BOOLEAN FASTCALL co_WinPosSetWindowPos(PWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx, INT cy, UINT flags);
 BOOLEAN FASTCALL co_WinPosShowWindow(PWND Window, INT Cmd);
 void FASTCALL co_WinPosSendSizeMove(PWND Window);
-PWND FASTCALL co_WinPosWindowFromPoint(PWND ScopeWin, POINT *WinPoint, USHORT* HitTest, BOOL Ignore);
+PWND APIENTRY co_WinPosWindowFromPoint(IN PWND ScopeWin, IN POINT *WinPoint, IN OUT USHORT* HitTest, IN BOOL Ignore);
 VOID FASTCALL co_WinPosActivateOtherWindow(PWND);
 PWND FASTCALL IntRealChildWindowFromPoint(PWND,LONG,LONG);
 BOOL FASTCALL IntScreenToClient(PWND,LPPOINT);