Signed-off-by: Rafał Harabień rafalh1992@o2.pl --- dlls/user32/input.c | 110 ++++++++++++++++++++++----------------------- dlls/user32/user_private.h | 8 ++++ 2 files changed, 61 insertions(+), 57 deletions(-)
diff --git a/dlls/user32/input.c b/dlls/user32/input.c index c475b19..a77127d 100644 --- a/dlls/user32/input.c +++ b/dlls/user32/input.c @@ -1243,45 +1243,38 @@ BOOL WINAPI UnloadKeyboardLayout(HKL hkl) return USER_Driver->pUnloadKeyboardLayout(hkl); }
-typedef struct __TRACKINGLIST { - TRACKMOUSEEVENT tme; - POINT pos; /* center of hover rectangle */ -} _TRACKINGLIST; - -/* FIXME: move tracking stuff into a per thread data */ -static _TRACKINGLIST tracking_info; -static UINT_PTR timer;
static void check_mouse_leave(HWND hwnd, int hittest) { - if (tracking_info.tme.hwndTrack != hwnd) + struct tracking_info *tracking_info = &get_user_thread_info()->tracking_info; + if (tracking_info->tme.hwndTrack != hwnd) { - if (tracking_info.tme.dwFlags & TME_NONCLIENT) - PostMessageW(tracking_info.tme.hwndTrack, WM_NCMOUSELEAVE, 0, 0); + if (tracking_info->tme.dwFlags & TME_NONCLIENT) + PostMessageW(tracking_info->tme.hwndTrack, WM_NCMOUSELEAVE, 0, 0); else - PostMessageW(tracking_info.tme.hwndTrack, WM_MOUSELEAVE, 0, 0); + PostMessageW(tracking_info->tme.hwndTrack, WM_MOUSELEAVE, 0, 0);
/* remove the TME_LEAVE flag */ - tracking_info.tme.dwFlags &= ~TME_LEAVE; + tracking_info->tme.dwFlags &= ~TME_LEAVE; } else { if (hittest == HTCLIENT) { - if (tracking_info.tme.dwFlags & TME_NONCLIENT) + if (tracking_info->tme.dwFlags & TME_NONCLIENT) { - PostMessageW(tracking_info.tme.hwndTrack, WM_NCMOUSELEAVE, 0, 0); + PostMessageW(tracking_info->tme.hwndTrack, WM_NCMOUSELEAVE, 0, 0); /* remove the TME_LEAVE flag */ - tracking_info.tme.dwFlags &= ~TME_LEAVE; + tracking_info->tme.dwFlags &= ~TME_LEAVE; } } else { - if (!(tracking_info.tme.dwFlags & TME_NONCLIENT)) + if (!(tracking_info->tme.dwFlags & TME_NONCLIENT)) { - PostMessageW(tracking_info.tme.hwndTrack, WM_MOUSELEAVE, 0, 0); + PostMessageW(tracking_info->tme.hwndTrack, WM_MOUSELEAVE, 0, 0); /* remove the TME_LEAVE flag */ - tracking_info.tme.dwFlags &= ~TME_LEAVE; + tracking_info->tme.dwFlags &= ~TME_LEAVE; } } } @@ -1292,6 +1285,7 @@ static void CALLBACK TrackMouseEventProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, { POINT pos; INT hoverwidth = 0, hoverheight = 0, hittest; + struct tracking_info *tracking_info = &get_user_thread_info()->tracking_info;
TRACE("hwnd %p, msg %04x, id %04lx, time %u\n", hwnd, uMsg, idEvent, dwTime);
@@ -1304,31 +1298,31 @@ static void CALLBACK TrackMouseEventProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, 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), + 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) + if (tracking_info->tme.dwFlags & TME_LEAVE) { check_mouse_leave(hwnd, hittest); }
- if (tracking_info.tme.hwndTrack != hwnd) + if (tracking_info->tme.hwndTrack != hwnd) { /* mouse is gone, stop tracking mouse hover */ - tracking_info.tme.dwFlags &= ~TME_HOVER; + tracking_info->tme.dwFlags &= ~TME_HOVER; }
/* see if we are tracking hovering for this hwnd */ - if (tracking_info.tme.dwFlags & TME_HOVER) + 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)) || - (abs(pos.y - tracking_info.pos.y) > (hoverheight / 2))) + 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 */ - tracking_info.pos = pos; + tracking_info->pos = pos; } else { @@ -1337,29 +1331,29 @@ static void CALLBACK TrackMouseEventProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, ScreenToClient(hwnd, &pos); TRACE("client cursor pos %s\n", wine_dbgstr_point(&pos));
- PostMessageW(tracking_info.tme.hwndTrack, WM_MOUSEHOVER, + PostMessageW(tracking_info->tme.hwndTrack, WM_MOUSEHOVER, get_key_state(), MAKELPARAM( pos.x, pos.y )); } else { - if (tracking_info.tme.dwFlags & TME_NONCLIENT) - PostMessageW(tracking_info.tme.hwndTrack, WM_NCMOUSEHOVER, + 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; + tracking_info->tme.dwFlags &= ~TME_HOVER; } }
/* stop the timer if the tracking list is empty */ - if (!(tracking_info.tme.dwFlags & (TME_HOVER | TME_LEAVE))) + if (!(tracking_info->tme.dwFlags & (TME_HOVER | TME_LEAVE))) { - KillSystemTimer(tracking_info.tme.hwndTrack, timer); - timer = 0; - tracking_info.tme.hwndTrack = 0; - tracking_info.tme.dwFlags = 0; - tracking_info.tme.dwHoverTime = 0; + KillSystemTimer(tracking_info->tme.hwndTrack, tracking_info->timer); + tracking_info->timer = 0; + tracking_info->tme.hwndTrack = 0; + tracking_info->tme.dwFlags = 0; + tracking_info->tme.dwHoverTime = 0; } }
@@ -1393,6 +1387,7 @@ TrackMouseEvent (TRACKMOUSEEVENT *ptme) POINT pos; DWORD hover_time; INT hittest; + struct tracking_info *tracking_info = &get_user_thread_info()->tracking_info;
TRACE("%x, %x, %p, %u\n", ptme->cbSize, ptme->dwFlags, ptme->hwndTrack, ptme->dwHoverTime);
@@ -1405,7 +1400,7 @@ TrackMouseEvent (TRACKMOUSEEVENT *ptme) /* fill the TRACKMOUSEEVENT struct with the current tracking for the given hwnd */ if (ptme->dwFlags & TME_QUERY ) { - *ptme = tracking_info.tme; + *ptme = tracking_info->tme; /* set cbSize in the case it's not initialized yet */ ptme->cbSize = sizeof(TRACKMOUSEEVENT);
@@ -1434,52 +1429,53 @@ TrackMouseEvent (TRACKMOUSEEVENT *ptme)
if (ptme->dwFlags & TME_CANCEL) { - if (tracking_info.tme.hwndTrack == ptme->hwndTrack) + if (tracking_info->tme.hwndTrack == ptme->hwndTrack) { - tracking_info.tme.dwFlags &= ~(ptme->dwFlags & ~TME_CANCEL); + tracking_info->tme.dwFlags &= ~(ptme->dwFlags & ~TME_CANCEL);
/* if we aren't tracking on hover or leave remove this entry */ - if (!(tracking_info.tme.dwFlags & (TME_HOVER | TME_LEAVE))) + if (!(tracking_info->tme.dwFlags & (TME_HOVER | TME_LEAVE))) { - KillSystemTimer(tracking_info.tme.hwndTrack, timer); - timer = 0; - tracking_info.tme.hwndTrack = 0; - tracking_info.tme.dwFlags = 0; - tracking_info.tme.dwHoverTime = 0; + KillSystemTimer(tracking_info->tme.hwndTrack, tracking_info->timer); + tracking_info->timer = 0; + tracking_info->tme.hwndTrack = 0; + tracking_info->tme.dwFlags = 0; + tracking_info->tme.dwHoverTime = 0; } } } else { /* In our implementation it's possible that another window will receive a * WM_MOUSEMOVE and call TrackMouseEvent before TrackMouseEventProc is * called. In such a situation post the WM_MOUSELEAVE now */ - if (tracking_info.tme.dwFlags & TME_LEAVE && tracking_info.tme.hwndTrack != NULL) + if (tracking_info->tme.dwFlags & TME_LEAVE && tracking_info->tme.hwndTrack != NULL) check_mouse_leave(hwnd, hittest);
- if (timer) + if (tracking_info->timer) { - KillSystemTimer(tracking_info.tme.hwndTrack, timer); - timer = 0; - tracking_info.tme.hwndTrack = 0; - tracking_info.tme.dwFlags = 0; - tracking_info.tme.dwHoverTime = 0; + KillSystemTimer(tracking_info->tme.hwndTrack, tracking_info->timer); + tracking_info->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 */ - tracking_info.tme = *ptme; - tracking_info.tme.dwHoverTime = hover_time; + tracking_info->tme = *ptme; + tracking_info->tme.dwHoverTime = hover_time;
/* Initialize HoverInfo variables even if not hover tracking */ - tracking_info.pos = pos; + tracking_info->pos = pos;
- timer = SetSystemTimer(tracking_info.tme.hwndTrack, (UINT_PTR)&tracking_info.tme, hover_time, TrackMouseEventProc); + tracking_info->timer = SetSystemTimer(tracking_info->tme.hwndTrack, (UINT_PTR)&tracking_info->tme, hover_time, TrackMouseEventProc); } }
return TRUE; }
+ /*********************************************************************** * GetMouseMovePointsEx [USER32] * diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h index 052fdd8..d7cfada 100644 --- a/dlls/user32/user_private.h +++ b/dlls/user32/user_private.h @@ -163,6 +163,13 @@ struct wm_char_mapping_data MSG get_msg; };
+/* data for TrackMouseEvent */ +struct tracking_info { + TRACKMOUSEEVENT tme; + POINT pos; /* center of hover rectangle */ + UINT_PTR timer; +}; + /* this is the structure stored in TEB->Win32ClientInfo */ /* no attempt is made to keep the layout compatible with the Windows one */ struct user_thread_info @@ -185,6 +192,7 @@ struct user_thread_info HWND top_window; /* Desktop window */ HWND msg_window; /* HWND_MESSAGE parent window */ RAWINPUT *rawinput; + struct tracking_info tracking_info; };
C_ASSERT( sizeof(struct user_thread_info) <= sizeof(((TEB *)0)->Win32ClientInfo) );