Dmitry Timoshkov : user: Various TrackMouseEvent fixes.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jul 24 13:15:10 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: 5292f976112d6e91f91ff6f46ff4634e3d2690de
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=5292f976112d6e91f91ff6f46ff4634e3d2690de

Author: Dmitry Timoshkov <dmitry at codeweavers.com>
Date:   Mon Jul 24 21:19:25 2006 +0900

user: Various TrackMouseEvent fixes.

- Use WINPOS_WindowFromPoint instead of WindowFromPoint in order to
  use hittest directly to simplify the code. 
- WM_NCMOUSEHOVER and WM_MOUSEHOVER take different parameters.

---

 dlls/user/input.c |   88 ++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 56 insertions(+), 32 deletions(-)

diff --git a/dlls/user/input.c b/dlls/user/input.c
index 46f4ae9..131bcd8 100644
--- a/dlls/user/input.c
+++ b/dlls/user/input.c
@@ -745,21 +745,26 @@ typedef struct __TRACKINGLIST {
 static _TRACKINGLIST tracking_info;
 static UINT_PTR timer;
 
-static void CALLBACK TrackMouseEventProc(HWND hwndUnused, UINT uMsg, UINT_PTR idEvent,
-    DWORD dwTime)
+static void CALLBACK TrackMouseEventProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent,
+                                         DWORD dwTime)
 {
     POINT pos;
-    POINT posClient;
-    HWND hwnd;
-    INT hoverwidth = 0, hoverheight = 0;
-    RECT client;
+    INT hoverwidth = 0, hoverheight = 0, hittest;
+
+    TRACE("hwnd %p, msg %04x, id %04x, time %lu\n", hwnd, uMsg, idEvent, dwTime);
 
     GetCursorPos(&pos);
-    hwnd = WindowFromPoint(pos);
+    hwnd = WINPOS_WindowFromPoint(hwnd, pos, &hittest);
+
+    TRACE("point %s hwnd %p hittest %d\n", wine_dbgstr_point(&pos), hwnd, hittest);
 
     SystemParametersInfoW(SPI_GETMOUSEHOVERWIDTH, 0, &hoverwidth, 0);
     SystemParametersInfoW(SPI_GETMOUSEHOVERHEIGHT, 0, &hoverheight, 0);
 
+    TRACE("tracked pos %s, current pos %s, hover width %d, hover height %d\n",
+           wine_dbgstr_point(&tracking_info.pos), wine_dbgstr_point(&pos),
+           hoverwidth, hoverheight);
+
     /* see if this tracking event is looking for TME_LEAVE and that the */
     /* mouse has left the window */
     if (tracking_info.tme.dwFlags & TME_LEAVE)
@@ -776,9 +781,7 @@ static void CALLBACK TrackMouseEventProc
         }
         else
         {
-            GetClientRect(hwnd, &client);
-            MapWindowPoints(hwnd, NULL, (LPPOINT)&client, 2);
-            if (PtInRect(&client, pos))
+            if (hittest == HTCLIENT)
             {
                 if (tracking_info.tme.dwFlags & TME_NONCLIENT)
                 {
@@ -799,29 +802,38 @@ static void CALLBACK TrackMouseEventProc
         }
     }
 
+    if (tracking_info.tme.hwndTrack != hwnd)
+    {
+        /* mouse is gone, stop tracking mouse hover */
+        tracking_info.tme.dwFlags &= ~TME_HOVER;
+    }
+
     /* see if we are tracking hovering for this hwnd */
     if (tracking_info.tme.dwFlags & TME_HOVER)
     {
         /* has the cursor moved outside the rectangle centered around pos? */
-        if ((abs(pos.x - tracking_info.pos.x) > (hoverwidth / 2.0)) ||
-            (abs(pos.y - tracking_info.pos.y) > (hoverheight / 2.0)))
+        if ((abs(pos.x - tracking_info.pos.x) > (hoverwidth / 2)) ||
+            (abs(pos.y - tracking_info.pos.y) > (hoverheight / 2)))
         {
-            /* record this new position as the current position and reset */
-            /* the iHoverTime variable to 0 */
+            /* record this new position as the current position */
             tracking_info.pos = pos;
         }
         else
         {
-            posClient.x = pos.x;
-            posClient.y = pos.y;
-            ScreenToClient(hwnd, &posClient);
+            if (hittest == HTCLIENT)
+            {
+                ScreenToClient(hwnd, &pos);
+                TRACE("client cursor pos %s\n", wine_dbgstr_point(&pos));
 
-            if (tracking_info.tme.dwFlags & TME_NONCLIENT)
-                PostMessageW(tracking_info.tme.hwndTrack, WM_NCMOUSEHOVER,
-                            get_key_state(), MAKELPARAM( posClient.x, posClient.y ));
-            else
                 PostMessageW(tracking_info.tme.hwndTrack, WM_MOUSEHOVER,
-                            get_key_state(), MAKELPARAM( posClient.x, posClient.y ));
+                             get_key_state(), MAKELPARAM( pos.x, pos.y ));
+            }
+            else
+            {
+                if (tracking_info.tme.dwFlags & TME_NONCLIENT)
+                    PostMessageW(tracking_info.tme.hwndTrack, WM_NCMOUSEHOVER,
+                                 hittest, MAKELPARAM( pos.x, pos.y ));
+            }
 
             /* stop tracking mouse hover */
             tracking_info.tme.dwFlags &= ~TME_HOVER;
@@ -831,10 +843,11 @@ static void CALLBACK TrackMouseEventProc
     /* stop the timer if the tracking list is empty */
     if (!(tracking_info.tme.dwFlags & (TME_HOVER | TME_LEAVE)))
     {
-        memset(&tracking_info, 0, sizeof(tracking_info));
-
-        KillSystemTimer(0, timer);
+        KillSystemTimer(tracking_info.tme.hwndTrack, timer);
         timer = 0;
+        tracking_info.tme.hwndTrack = 0;
+        tracking_info.tme.dwFlags = 0;
+        tracking_info.tme.dwHoverTime = 0;
     }
 }
 
@@ -867,8 +880,9 @@ TrackMouseEvent (TRACKMOUSEEVENT *ptme)
     HWND hwnd;
     POINT pos;
     DWORD hover_time;
+    INT hittest;
 
-    TRACE("%lx, %lx, %p, %lx\n", ptme->cbSize, ptme->dwFlags, ptme->hwndTrack, ptme->dwHoverTime);
+    TRACE("%lx, %lx, %p, %lu\n", ptme->cbSize, ptme->dwFlags, ptme->hwndTrack, ptme->dwHoverTime);
 
     if (ptme->cbSize != sizeof(TRACKMOUSEEVENT)) {
         WARN("wrong TRACKMOUSEEVENT size from app\n");
@@ -897,7 +911,8 @@ TrackMouseEvent (TRACKMOUSEEVENT *ptme)
         SystemParametersInfoW(SPI_GETMOUSEHOVERTIME, 0, &hover_time, 0);
 
     GetCursorPos(&pos);
-    hwnd = WindowFromPoint(pos);
+    hwnd = WINPOS_WindowFromPoint(ptme->hwndTrack, pos, &hittest);
+    TRACE("point %s hwnd %p hittest %d\n", wine_dbgstr_point(&pos), hwnd, hittest);
 
     if (ptme->dwFlags & ~(TME_CANCEL | TME_HOVER | TME_LEAVE | TME_NONCLIENT))
         FIXME("Unknown flag(s) %08lx\n", ptme->dwFlags & ~(TME_CANCEL | TME_HOVER | TME_LEAVE | TME_NONCLIENT));
@@ -911,13 +926,23 @@ TrackMouseEvent (TRACKMOUSEEVENT *ptme)
             /* if we aren't tracking on hover or leave remove this entry */
             if (!(tracking_info.tme.dwFlags & (TME_HOVER | TME_LEAVE)))
             {
-                memset(&tracking_info, 0, sizeof(tracking_info));
-
-                KillSystemTimer(0, timer);
+                KillSystemTimer(tracking_info.tme.hwndTrack, timer);
                 timer = 0;
+                tracking_info.tme.hwndTrack = 0;
+                tracking_info.tme.dwFlags = 0;
+                tracking_info.tme.dwHoverTime = 0;
             }
         }
     } else {
+        if (timer)
+        {
+            KillSystemTimer(tracking_info.tme.hwndTrack, timer);
+            timer = 0;
+            tracking_info.tme.hwndTrack = 0;
+            tracking_info.tme.dwFlags = 0;
+            tracking_info.tme.dwHoverTime = 0;
+        }
+
         if (ptme->hwndTrack == hwnd)
         {
             /* Adding new mouse event to the tracking list */
@@ -927,8 +952,7 @@ TrackMouseEvent (TRACKMOUSEEVENT *ptme)
             /* Initialize HoverInfo variables even if not hover tracking */
             tracking_info.pos = pos;
 
-            if (!timer)
-                timer = SetSystemTimer(0, 0, hover_time, TrackMouseEventProc);
+            timer = SetSystemTimer(tracking_info.tme.hwndTrack, 0, hover_time, TrackMouseEventProc);
         }
     }
 




More information about the wine-cvs mailing list