[NtUser]
authorJames Tabor <james.tabor@reactos.org>
Sat, 18 Aug 2012 23:01:55 +0000 (23:01 +0000)
committerJames Tabor <james.tabor@reactos.org>
Sat, 18 Aug 2012 23:01:55 +0000 (23:01 +0000)
- Patch based on Daniel Jelinski: search more aggressively for a window under a tooltip and better HTTRANSPARENT handling. When the test patch is applied, ReactOS passes the new tests.

References:
http://www.winehq.org/pipermail/wine-patches/2012-July/116429.html
http://www.winehq.org/pipermail/wine-patches/2012-August/116776.html
http://www.winehq.org/pipermail/wine-patches/2012-August/116777.html
http://www.winehq.org/pipermail/wine-devel/2012-August/096681.html

svn path=/trunk/; revision=57104

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

index 7558931..d7ef793 100644 (file)
@@ -42,6 +42,12 @@ IntChildrenWindowFromPoint(PWND pWndTop, INT x, INT y)
 {
     PWND pWnd, pWndChild;
 
+    if ( !pWndTop )
+    {
+       pWndTop = UserGetDesktopWindow();
+       if ( !pWndTop ) return NULL;
+    }
+
     if (!(pWndTop->style & WS_VISIBLE)) return NULL;
     if ((pWndTop->style & WS_DISABLED)) return NULL;
     if (!IntPtInWindow(pWndTop, x, y)) return NULL;
@@ -1338,7 +1344,7 @@ BOOL co_IntProcessMouseMessage(MSG* msg, BOOL* RemoveMessages, UINT first, UINT
     pwndDesktop = UserGetDesktopWindow();
     MessageQueue = pti->MessageQueue;
     CurInfo = IntGetSysCursorInfo();
-    pwndMsg = UserGetWindowObject(msg->hwnd);
+    pwndMsg = ValidateHwndNoErr(msg->hwnd);
     clk_msg = MessageQueue->msgDblClk;
     pDesk = pwndDesktop->head.rpdesk;
 
@@ -1350,8 +1356,9 @@ BOOL co_IntProcessMouseMessage(MSG* msg, BOOL* RemoveMessages, UINT first, UINT
         if (pwndMsg) UserReferenceObject(pwndMsg);
     }
     else
-    {
-        pwndMsg = co_WinPosWindowFromPoint(pwndMsg, &msg->pt, &hittest);
+    {   // Fix wine Msg test_HTTRANSPARENT. Start with a NULL window.
+        // http://www.winehq.org/pipermail/wine-patches/2012-August/116776.html
+        pwndMsg = co_WinPosWindowFromPoint(NULL, &msg->pt, &hittest);
     }
 
     TRACE("Got mouse message for 0x%x, hittest: 0x%x\n", msg->hwnd, hittest );
index a70cd38..4846f6a 100644 (file)
@@ -2111,7 +2111,7 @@ co_WinPosSearchChildren(
         {
             for (phWnd = List; *phWnd; ++phWnd)
             {
-                if (!(pwndChild = UserGetWindowObject(*phWnd)))
+                if (!(pwndChild = ValidateHwndNoErr(*phWnd)))
                 {
                     continue;
                 }
@@ -2130,13 +2130,18 @@ co_WinPosSearchChildren(
         }
     }
 
-    *HitTest = (USHORT)co_IntSendMessage(ScopeWin->head.h, WM_NCHITTEST, 0,
-                                         MAKELONG(Point->x, Point->y));
-    if ((*HitTest) == (USHORT)HTTRANSPARENT)
+    if (ScopeWin->head.pti == PsGetCurrentThreadWin32Thread())
     {
-         UserDereferenceObject(ScopeWin);
-         return NULL;
+       *HitTest = (USHORT)co_IntSendMessage(ScopeWin->head.h, WM_NCHITTEST, 0,
+                                            MAKELONG(Point->x, Point->y));
+       if ((*HitTest) == (USHORT)HTTRANSPARENT)
+       {
+           UserDereferenceObject(ScopeWin);
+           return NULL;
+       }
     }
+    else
+       *HitTest = HTCLIENT;
 
     return ScopeWin;
 }
@@ -2163,7 +2168,7 @@ co_WinPosWindowFromPoint(PWND ScopeWin, POINT *WinPoint, USHORT* HitTest)
    Window = co_WinPosSearchChildren(ScopeWin, &Point, HitTest);
 
    UserDerefObjectCo(ScopeWin);
-   if(Window)
+   if (Window)
        ASSERT_REFS_CO(Window);
    ASSERT_REFS_CO(ScopeWin);
 
@@ -2193,7 +2198,7 @@ IntRealChildWindowFromPoint(PWND Parent, LONG x, LONG y)
       for (phWnd = List; *phWnd; phWnd++)
       {
          PWND Child;
-         if ((Child = UserGetWindowObject(*phWnd)))
+         if ((Child = ValidateHwndNoErr(*phWnd)))
          {
             if ( Child->style & WS_VISIBLE && IntPtInWindow(Child, Pt.x, Pt.y) )
             {
@@ -2238,7 +2243,7 @@ IntChildWindowFromPointEx(PWND Parent, LONG x, LONG y, UINT uiFlags)
       for (phWnd = List; *phWnd; phWnd++)
       {
          PWND Child;
-         if ((Child = UserGetWindowObject(*phWnd)))
+         if ((Child = ValidateHwndNoErr(*phWnd)))
          {
             if (uiFlags & (CWP_SKIPINVISIBLE|CWP_SKIPDISABLED))
             {
@@ -3098,9 +3103,9 @@ NtUserWindowFromPoint(LONG X, LONG Y)
       //pti = PsGetCurrentThreadWin32Thread();
       Window = co_WinPosWindowFromPoint(DesktopWindow, &pt, &hittest);
 
-      if(Window)
+      if (Window)
       {
-         Ret = Window->head.h;
+         Ret = UserHMGetHandle(Window);
 
          RETURN( Ret);
       }