user: Add more mouse tracking tests,
fix them by adding a mouse tracking hook into process_mouse_message
Dmitry Timoshkov
dmitry at codeweavers.com
Thu Jul 27 08:56:24 CDT 2006
Hello,
Changelog:
Add more mouse tracking tests, fix them by adding a mouse tracking
hook into process_mouse_message.
diff -up cvs/hq/wine/dlls/user/input.c wine/dlls/user/input.c
--- cvs/hq/wine/dlls/user/input.c 2006-07-27 14:00:23.000000000 +0900
+++ wine/dlls/user/input.c 2006-07-27 15:58:25.000000000 +0900
@@ -741,7 +741,7 @@ typedef struct __TRACKINGLIST {
POINT pos; /* center of hover rectangle */
} _TRACKINGLIST;
-/* FIXME: move tracking stuff into a per thread data */
+/* FIXME: tracking stuff probably needs to be moved into a per desktop data */
static _TRACKINGLIST tracking_info;
static UINT_PTR timer;
@@ -852,6 +852,43 @@ static void CALLBACK TrackMouseEventProc
}
+void update_mouse_tracking_state(const MSG *msg, INT hittest)
+{
+ POINT new_pos;
+ INT hover_width = 0, hover_height = 0;
+
+ SystemParametersInfoW(SPI_GETMOUSEHOVERWIDTH, 0, &hover_width, 0);
+ SystemParametersInfoW(SPI_GETMOUSEHOVERHEIGHT, 0, &hover_height, 0);
+
+ new_pos.x = LOWORD(msg->lParam);
+ new_pos.y = HIWORD(msg->lParam);
+
+ if (hittest == HTCLIENT)
+ ClientToScreen(msg->hwnd, &new_pos);
+
+ if (msg->hwnd != tracking_info.tme.hwndTrack)
+ {
+ /* 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(new_pos.x - tracking_info.pos.x) > (hover_width / 2)) ||
+ (abs(new_pos.y - tracking_info.pos.y) > (hover_height / 2)))
+ {
+ KillSystemTimer(tracking_info.tme.hwndTrack, timer);
+ timer = SetSystemTimer(tracking_info.tme.hwndTrack, 0, tracking_info.tme.dwHoverTime, TrackMouseEventProc);
+ }
+ }
+
+ /* record this new position as the current position */
+ tracking_info.pos = new_pos;
+}
+
+
/***********************************************************************
* TrackMouseEvent [USER32]
*
@@ -936,17 +973,10 @@ TrackMouseEvent (TRACKMOUSEEVENT *ptme)
}
}
} 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)
{
+ if (timer) KillSystemTimer(tracking_info.tme.hwndTrack, timer);
+
/* Adding new mouse event to the tracking list */
tracking_info.tme = *ptme;
tracking_info.tme.dwHoverTime = hover_time;
diff -up cvs/hq/wine/dlls/user/message.c wine/dlls/user/message.c
--- cvs/hq/wine/dlls/user/message.c 2006-07-27 14:00:24.000000000 +0900
+++ wine/dlls/user/message.c 2006-07-27 15:55:44.000000000 +0900
@@ -54,6 +54,9 @@ WINE_DECLARE_DEBUG_CHANNEL(key);
#define SYS_TIMER_RATE 55 /* min. timer rate in ms (actually 54.925)*/
+/* for TrackMouseEvent in input.c */
+void update_mouse_tracking_state(const MSG *msg, INT hittest);
+
/* description of the data fields that need to be packed along with a sent message */
struct packed_message
{
@@ -1779,6 +1782,8 @@ static BOOL process_mouse_message( MSG *
return FALSE;
}
+ update_mouse_tracking_state( msg, hittest );
+
if ((hittest == HTERROR) || (hittest == HTNOWHERE))
{
SendMessageW( msg->hwnd, WM_SETCURSOR, (WPARAM)msg->hwnd,
diff -up cvs/hq/wine/dlls/user/tests/msg.c wine/dlls/user/tests/msg.c
--- cvs/hq/wine/dlls/user/tests/msg.c 2006-07-27 14:00:24.000000000 +0900
+++ wine/dlls/user/tests/msg.c 2006-07-27 16:04:02.000000000 +0900
@@ -7624,7 +7624,7 @@ static const struct message WmMouseHover
{ 0 }
};
-static void pump_msg_loop_timeout(DWORD timeout, BOOL inject_mouse_move)
+static void pump_msg_loop_timeout(DWORD timeout, BOOL inject_mouse_move, INT dx, INT dy)
{
MSG msg;
DWORD start_ticks, end_ticks;
@@ -7658,9 +7658,7 @@ static void pump_msg_loop_timeout(DWORD
/* inject WM_MOUSEMOVE to see how it changes tracking */
if (inject_mouse_move && start_ticks + timeout / 2 >= end_ticks)
{
- mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
- mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
-
+ mouse_event(MOUSEEVENTF_MOVE, dx, dy, 0, 0);
inject_mouse_move = FALSE;
}
} while (start_ticks + timeout >= end_ticks);
@@ -7673,7 +7671,8 @@ static void test_TrackMouseEvent(void)
BOOL ret;
HWND hwnd, hchild;
RECT rc_parent, rc_child;
- UINT default_hover_time, hover_width = 0, hover_height = 0;
+ DWORD default_hover_time;
+ INT hover_width = 0, hover_height = 0;
#define track_hover(track_hwnd, track_hover_time) \
tme.cbSize = sizeof(tme); \
@@ -7781,7 +7780,25 @@ static void test_TrackMouseEvent(void)
track_hover(hwnd, 0);
track_query(TME_HOVER, hwnd, default_hover_time);
- pump_msg_loop_timeout(default_hover_time, FALSE);
+ track_hover(hchild, 0);
+ track_query(TME_HOVER, hwnd, default_hover_time);
+
+ pump_msg_loop_timeout(default_hover_time, FALSE, 0, 0);
+ ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
+
+ track_query(0, NULL, 0);
+
+ track_hover(hwnd, HOVER_DEFAULT);
+ track_query(TME_HOVER, hwnd, default_hover_time);
+
+ Sleep(default_hover_time / 2);
+ mouse_event(MOUSEEVENTF_MOVE, -1, -1, 0, 0);
+ while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+ flush_sequence();
+
+ track_query(TME_HOVER, hwnd, default_hover_time);
+
+ pump_msg_loop_timeout(default_hover_time / 2, FALSE, 0, 0);
ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
track_query(0, NULL, 0);
@@ -7790,12 +7807,18 @@ static void test_TrackMouseEvent(void)
track_query(TME_HOVER, hwnd, default_hover_time);
Sleep(default_hover_time / 2);
- mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
- mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
+ mouse_event(MOUSEEVENTF_MOVE, -hover_width, -hover_height, 0, 0);
+ while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+ flush_sequence();
+
+ track_query(TME_HOVER, hwnd, default_hover_time);
+
+ pump_msg_loop_timeout(default_hover_time / 2, FALSE, 0, 0);
+ ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
track_query(TME_HOVER, hwnd, default_hover_time);
- pump_msg_loop_timeout(default_hover_time / 2, FALSE);
+ pump_msg_loop_timeout(default_hover_time / 2, FALSE, 0, 0);
ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
track_query(0, NULL, 0);
@@ -7803,7 +7826,7 @@ static void test_TrackMouseEvent(void)
track_hover(hwnd, HOVER_DEFAULT);
track_query(TME_HOVER, hwnd, default_hover_time);
- pump_msg_loop_timeout(default_hover_time, TRUE);
+ pump_msg_loop_timeout(default_hover_time, TRUE, hover_width, hover_height);
ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
track_query(0, NULL, 0);
@@ -7812,6 +7835,8 @@ static void test_TrackMouseEvent(void)
track_query(TME_HOVER, hwnd, default_hover_time);
track_hover_cancel(hwnd);
+ track_query(0, NULL, 0);
+
DestroyWindow(hwnd);
#undef track_hover
More information about the wine-patches
mailing list