ReactOS 0.4.15-dev-8241-g63935f8
TrackMouseEvent.c File Reference
#include "precomp.h"
Include dependency graph for TrackMouseEvent.c:

Go to the source code of this file.

Macros

#define FLUSH_MESSAGES(expected, notexpected)
 
#define EXPECT_TME_FLAGS(hWnd, expected)
 
#define MOVE_CURSOR(x, y)
 

Functions

static int get_iwnd (HWND hWnd)
 
LRESULT CALLBACK TmeTestProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static LRESULT CALLBACK MouseLLHookProc (int nCode, WPARAM wParam, LPARAM lParam)
 
static LRESULT CALLBACK MouseHookProc (int nCode, WPARAM wParam, LPARAM lParam)
 
static void FlushMessages ()
 
static void create_test_windows ()
 
static void destroy_test_window ()
 
static void TmeStartTracking (HWND hwnd, DWORD Flags)
 
DWORD TmeQuery (HWND hwnd)
 
void Test_TrackMouseEvent ()
 
 START_TEST (TrackMouseEvent)
 

Variables

static HWND hWnd1
 
static HWND hWnd2
 
static HWND hWnd3
 
static HHOOK hMouseHookLL
 
static HHOOK hMouseHook
 
static int ignore_timer = 0
 
static int ignore_mouse = 0
 
static int ignore_mousell = 0
 
static MSG_ENTRY mousemove2_chain []
 
static MSG_ENTRY mousehover2_chain []
 
static MSG_ENTRY mouseleave2to1_chain []
 
static MSG_ENTRY mouseleave2to3_chain []
 
static MSG_ENTRY mousehover3_chain []
 
static MSG_ENTRY mousehover3_nomove_chain []
 
static MSG_ENTRY mousehover3_droptimer_chain []
 
static MSG_ENTRY mousehover3_dropmouse_chain []
 
static MSG_ENTRY mousehover3_dropmousell_chain []
 
static MSG_ENTRY mouseleave3to2_dropmouse_chain []
 
static MSG_ENTRY mouseleave3to2_dropmousell_chain []
 
static MSG_ENTRY mouseleave3_remainging_chain []
 

Macro Definition Documentation

◆ EXPECT_TME_FLAGS

#define EXPECT_TME_FLAGS (   hWnd,
  expected 
)
Value:
ok(flags == (expected),"wrong tme flags. expected %li, and got %li\n", (DWORD)(expected), flags); \
}
DWORD TmeQuery(HWND hwnd)
HWND hWnd
Definition: settings.c:17
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
BOOL expected
Definition: store.c:2063

Definition at line 157 of file TrackMouseEvent.c.

◆ FLUSH_MESSAGES

#define FLUSH_MESSAGES (   expected,
  notexpected 
)
Value:
{ EXPECT_QUEUE_STATUS(expected, notexpected);\
FlushMessages();\
}
#define EXPECT_QUEUE_STATUS(expected, notexpected)
Definition: msgtrace.h:66

Definition at line 96 of file TrackMouseEvent.c.

◆ MOVE_CURSOR

#define MOVE_CURSOR (   x,
  y 
)
Value:
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define MOUSEEVENTF_ABSOLUTE
Definition: winuser.h:1194
#define SM_CYVIRTUALSCREEN
Definition: winuser.h:1039
void WINAPI mouse_event(_In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ ULONG_PTR)
#define SM_CXVIRTUALSCREEN
Definition: winuser.h:1038
#define MOUSEEVENTF_MOVE
Definition: winuser.h:1183
int WINAPI GetSystemMetrics(_In_ int)

Definition at line 162 of file TrackMouseEvent.c.

Function Documentation

◆ create_test_windows()

static void create_test_windows ( )
static

Definition at line 101 of file TrackMouseEvent.c.

102{
105 ok(hMouseHook!=NULL,"failed to set hook\n");
106 ok(hMouseHookLL!=NULL,"failed to set hook\n");
107
108 RegisterSimpleClass(TmeTestProc, L"testClass");
109
110 hWnd1 = CreateWindowW(L"testClass", L"test", WS_OVERLAPPEDWINDOW,
111 100, 100, 500, 500, NULL, NULL, 0, NULL);
112 hWnd2 = CreateWindowW(L"testClass", L"test", WS_CHILD,
113 50, 50, 200, 200, hWnd1, NULL, 0, NULL);
114 hWnd3 = CreateWindowW(L"testClass", L"test", WS_CHILD,
115 150, 150, 200, 200, hWnd1, NULL, 0, NULL);
116
123 //SetWindowPos (hWnd3, HWND_TOP, 0,0,0,0, SWP_NOMOVE|SWP_NOREDRAW);
124}
static HHOOK hMouseHook
static HHOOK hMouseHookLL
static HWND hWnd3
LRESULT CALLBACK TmeTestProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
static HWND hWnd1
static LRESULT CALLBACK MouseLLHookProc(int nCode, WPARAM wParam, LPARAM lParam)
static HWND hWnd2
static LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam)
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define L(x)
Definition: ntvdm.h:50
#define WS_CHILD
Definition: pedump.c:617
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
static __inline ATOM RegisterSimpleClass(WNDPROC lpfnWndProc, LPCWSTR lpszClassName)
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
#define SW_SHOWNORMAL
Definition: winuser.h:770
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
HHOOK WINAPI SetWindowsHookExW(_In_ int, _In_ HOOKPROC, _In_opt_ HINSTANCE, _In_ DWORD)
#define WH_MOUSE_LL
Definition: winuser.h:44
#define WH_MOUSE
Definition: winuser.h:37
BOOL WINAPI UpdateWindow(_In_ HWND)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4316
#define SW_SHOW
Definition: winuser.h:775

Referenced by Test_TrackMouseEvent().

◆ destroy_test_window()

static void destroy_test_window ( )
static

Definition at line 126 of file TrackMouseEvent.c.

127{
129 UnregisterClassW(L"testClass", 0);
132}
BOOL WINAPI UnhookWindowsHookEx(_In_ HHOOK)
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
BOOL WINAPI DestroyWindow(_In_ HWND)

Referenced by Test_TrackMouseEvent().

◆ FlushMessages()

static void FlushMessages ( )
static

Definition at line 74 of file TrackMouseEvent.c.

75{
76 MSG msg;
77
78 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
79 {
80 int iwnd = get_iwnd(msg.hwnd);
81 if(iwnd)
82 {
83 if(msg.message == WM_SYSTIMER)
84 {
85 RECORD_MESSAGE(iwnd, msg.message, POST,msg.wParam,0);
86 if(ignore_timer)
87 continue;
88 }
89 else if(!(msg.message > WM_USER || !iwnd || IsDWmMsg(msg.message) || IseKeyMsg(msg.message)))
90 RECORD_MESSAGE(iwnd, msg.message, POST,0,0);
91 }
93 }
94}
static int get_iwnd(HWND hWnd)
static int ignore_timer
#define msg(x)
Definition: auth_time.c:54
#define WM_SYSTIMER
Definition: comctl32.h:119
static BOOL IsDWmMsg(UINT msg)
Definition: msgtrace.h:39
#define RECORD_MESSAGE(...)
Definition: msgtrace.h:60
@ POST
Definition: msgtrace.h:7
static BOOL IseKeyMsg(UINT msg)
Definition: msgtrace.h:52
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
#define PM_REMOVE
Definition: winuser.h:1196
#define PeekMessage
Definition: winuser.h:5839
#define WM_USER
Definition: winuser.h:1895

Referenced by Test_TrackMouseEvent().

◆ get_iwnd()

static int get_iwnd ( HWND  hWnd)
static

Definition at line 14 of file TrackMouseEvent.c.

15{
16 if(hWnd == hWnd1) return 1;
17 else if(hWnd == hWnd2) return 2;
18 else if(hWnd == hWnd3) return 3;
19 else return 0;
20}

Referenced by FlushMessages(), MouseHookProc(), and TmeTestProc().

◆ MouseHookProc()

static LRESULT CALLBACK MouseHookProc ( int  nCode,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 63 of file TrackMouseEvent.c.

64{
69 if(ignore_mouse)
70 return TRUE;
71 return ret;
72}
static int ignore_mouse
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define TRUE
Definition: types.h:120
int ret
LONG_PTR LRESULT
Definition: windef.h:209
LRESULT WINAPI CallNextHookEx(_In_opt_ HHOOK, _In_ int, _In_ WPARAM, _In_ LPARAM)

Referenced by create_test_windows().

◆ MouseLLHookProc()

static LRESULT CALLBACK MouseLLHookProc ( int  nCode,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 53 of file TrackMouseEvent.c.

54{
59 return TRUE;
60 return ret;
61}
static int ignore_mousell

Referenced by create_test_windows().

◆ START_TEST()

START_TEST ( TrackMouseEvent  )

Definition at line 445 of file TrackMouseEvent.c.

446{
448}
void Test_TrackMouseEvent()

◆ Test_TrackMouseEvent()

void Test_TrackMouseEvent ( )

Definition at line 271 of file TrackMouseEvent.c.

272{
273 MOVE_CURSOR(0,0);
276 EMPTY_CACHE();
277
278 /* the mouse moves over hwnd2 */
279 MOVE_CURSOR(220,220);
283
284 /* Begin tracking mouse events for hWnd2 */
289
290 /* the mouse hovers hwnd2 */
291 MOVE_CURSOR(221, 221);
292 Sleep(100);
297
298 /* the mouse leaves hwnd2 and moves to hwnd1 */
299 MOVE_CURSOR(150, 150);
304
307
308 /* the mouse moves over hwnd2 */
309 MOVE_CURSOR(220,220);
313
316
317 /* Begin tracking mouse events for hWnd2 */
325
326 /* the mouse moves from hwnd2 to the intersection of hwnd2 and hwnd3 */
327 MOVE_CURSOR(300,300);
331
334
335 /* the mouse moves from hwnd2 to hwnd3 */
336 MOVE_CURSOR(400,400);
340
343
344 /* Begin tracking mouse events for hWnd3 */
349
350 /* the mouse hovers hwnd3 */
351 MOVE_CURSOR(401,401);
352 Sleep(100);
357
360
361 /* Begin tracking mouse events for hWnd3 */
366
367 /* make sure that the timer will fire before the mouse moves */
368 Sleep(100);
372
373 Sleep(100);
376
377 /* the mouse hovers hwnd3 and the timer is not dispatched*/
380 MOVE_CURSOR(400,400);
381 Sleep(100);
383 FLUSH_MESSAGES(QS_TIMER|QS_MOUSEMOVE, 0); /* the loop drops WM_SYSTIMER */
384 EXPECT_TME_FLAGS(hWnd3, TME_HOVER|TME_LEAVE); /* TME_HOVER is still active */
385 COMPARE_CACHE(mousehover3_droptimer_chain); /* we get no WM_MOUSEHOVER */
387
388 /* the mouse hovers hwnd3 and mouse message is dropped by WH_MOUSE_LL */
390 MOVE_CURSOR(402,402);
391 Sleep(100);
393 FLUSH_MESSAGES(QS_TIMER, QS_MOUSEMOVE); /* WH_MOUSE_LL drops WM_MOUSEMOVE */
395 COMPARE_CACHE(mousehover3_dropmousell_chain); /* we get WM_MOUSEHOVER normaly */
397
400
401 /* the mouse hovers hwnd3 and mouse message is dropped by WH_MOUSE */
404 MOVE_CURSOR(401,401);
405 Sleep(100);
407 FLUSH_MESSAGES(QS_TIMER|QS_MOUSEMOVE, 0); /* WH_MOUSE drops WM_MOUSEMOVE */
409 COMPARE_CACHE(mousehover3_dropmouse_chain); /* we get WM_MOUSEHOVER normaly */
411
414
415 /* the mouse leaves hwnd3 and moves to hwnd2 and mouse message is dropped by WH_MOUSE_LL */
418 MOVE_CURSOR(220,220);
419 FLUSH_MESSAGES(0, QS_MOUSEMOVE|QS_TIMER); /* WH_MOUSE drops WM_MOUSEMOVE */
420 EXPECT_TME_FLAGS(hWnd3, TME_LEAVE); /* all flags are removed */
421 COMPARE_CACHE(mouseleave3to2_dropmousell_chain); /* we get no WM_MOUSELEAVE */
423
426
427 /* the mouse leaves hwnd3 and moves to hwnd2 and mouse message is dropped by WH_MOUSE */
429 MOVE_CURSOR(220,220);
430 FLUSH_MESSAGES(QS_MOUSEMOVE, QS_TIMER); /* WH_MOUSE drops WM_MOUSEMOVE */
431 EXPECT_TME_FLAGS(hWnd3, 0); /* all flags are removed */
432 COMPARE_CACHE(mouseleave3to2_dropmouse_chain); /* we get no WM_MOUSELEAVE */
434
435 /* after WH_MOUSE drops WM_MOUSEMOVE, WM_MOUSELEAVE is still in the queue */
438
441
443}
static MSG_ENTRY mousehover3_nomove_chain[]
static MSG_ENTRY mouseleave3to2_dropmouse_chain[]
static void FlushMessages()
static MSG_ENTRY mousehover3_droptimer_chain[]
static MSG_ENTRY mouseleave3to2_dropmousell_chain[]
#define MOVE_CURSOR(x, y)
static void TmeStartTracking(HWND hwnd, DWORD Flags)
static MSG_ENTRY mouseleave2to1_chain[]
static void destroy_test_window()
static MSG_ENTRY mousehover3_chain[]
#define EXPECT_TME_FLAGS(hWnd, expected)
static MSG_ENTRY mousehover3_dropmouse_chain[]
static MSG_ENTRY mousehover3_dropmousell_chain[]
static MSG_ENTRY mousemove2_chain[]
#define FLUSH_MESSAGES(expected, notexpected)
static void create_test_windows()
static MSG_ENTRY mouseleave2to3_chain[]
static MSG_ENTRY mousehover2_chain[]
static MSG_ENTRY mouseleave3_remainging_chain[]
#define FALSE
Definition: types.h:117
MSG_ENTRY empty_chain[]
Definition: msgtrace.c:20
#define EMPTY_CACHE()
Definition: msgtrace.h:59
#define COMPARE_CACHE(msg_chain)
Definition: msgtrace.h:57
#define TME_LEAVE
Definition: commctrl.h:4981
#define TME_HOVER
Definition: commctrl.h:4980
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
#define QS_MOUSEMOVE
Definition: winuser.h:875
#define QS_TIMER
Definition: winuser.h:878
#define QS_POSTMESSAGE
Definition: winuser.h:877

Referenced by START_TEST().

◆ TmeQuery()

DWORD TmeQuery ( HWND  hwnd)

Definition at line 147 of file TrackMouseEvent.c.

148{
149 TRACKMOUSEEVENT tme;
150 tme.cbSize = sizeof(tme);
152 tme.hwndTrack = hwnd;
153 TrackMouseEvent(&tme);
154 return tme.dwFlags;
155}
#define TME_QUERY
Definition: commctrl.h:4983
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
BOOL WINAPI TrackMouseEvent(_Inout_ LPTRACKMOUSEEVENT)

◆ TmeStartTracking()

static void TmeStartTracking ( HWND  hwnd,
DWORD  Flags 
)
static

Definition at line 134 of file TrackMouseEvent.c.

135{
136 TRACKMOUSEEVENT tme;
137 tme.cbSize = sizeof(tme);
138 tme.dwFlags = Flags;
139 tme.hwndTrack = hwnd;
140 tme.dwHoverTime = 1;
141 if(!TrackMouseEvent(&tme))
142 {
143 trace("failed!\n");
144 }
145}
#define trace
Definition: atltest.h:70
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by Test_TrackMouseEvent().

◆ TmeTestProc()

LRESULT CALLBACK TmeTestProc ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 22 of file TrackMouseEvent.c.

23{
24 int iwnd = get_iwnd(hWnd);
25
26 if(message == WM_PAINT)
27 {
28 PAINTSTRUCT ps;
29 BeginPaint(hWnd, &ps);
31 EndPaint(hWnd, &ps);
32 }
33
34 if(message > WM_USER || !iwnd || IsDWmMsg(message) || IseKeyMsg(message))
36
37 switch(message)
38 {
40 case WM_IME_NOTIFY :
41 case WM_GETICON :
42 case WM_GETTEXT:
43 break;
44 case WM_SYSTIMER:
45 ok(0, "Got unexpected WM_SYSTIMER in the winproc. wParam=%d\n", wParam);
46 break;
47 default:
48 RECORD_MESSAGE(iwnd, message, SENT, 0,0);
49 }
51}
@ SENT
Definition: msgtrace.h:6
#define DefWindowProc
Definition: ros2win.h:31
Definition: tftpd.h:60
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
#define WM_PAINT
Definition: winuser.h:1620
#define WM_IME_NOTIFY
Definition: winuser.h:1830
#define WM_GETTEXT
Definition: winuser.h:1618
#define WM_IME_SETCONTEXT
Definition: winuser.h:1829
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)

Referenced by create_test_windows().

Variable Documentation

◆ hMouseHook

HHOOK hMouseHook
static

Definition at line 11 of file TrackMouseEvent.c.

Referenced by create_test_windows(), destroy_test_window(), and MouseHookProc().

◆ hMouseHookLL

HHOOK hMouseHookLL
static

Definition at line 11 of file TrackMouseEvent.c.

Referenced by create_test_windows(), destroy_test_window(), and MouseLLHookProc().

◆ hWnd1

HWND hWnd1
static

Definition at line 10 of file TrackMouseEvent.c.

Referenced by create_test_windows(), destroy_test_window(), and get_iwnd().

◆ hWnd2

HWND hWnd2
static

Definition at line 10 of file TrackMouseEvent.c.

Referenced by create_test_windows(), get_iwnd(), and Test_TrackMouseEvent().

◆ hWnd3

HWND hWnd3
static

Definition at line 10 of file TrackMouseEvent.c.

Referenced by create_test_windows(), get_iwnd(), and Test_TrackMouseEvent().

◆ ignore_mouse

int ignore_mouse = 0
static

Definition at line 12 of file TrackMouseEvent.c.

Referenced by MouseHookProc(), and Test_TrackMouseEvent().

◆ ignore_mousell

int ignore_mousell = 0
static

Definition at line 12 of file TrackMouseEvent.c.

Referenced by MouseLLHookProc(), and Test_TrackMouseEvent().

◆ ignore_timer

int ignore_timer = 0
static

Definition at line 12 of file TrackMouseEvent.c.

Referenced by FlushMessages(), and Test_TrackMouseEvent().

◆ mousehover2_chain

MSG_ENTRY mousehover2_chain[]
static
Initial value:
={
{0,0}}
struct tagHOOK HOOK
#define WM_MOUSEHOVER
Definition: commctrl.h:4974
#define ID_TME_TIMER
Definition: undocuser.h:81
#define WM_NCHITTEST
Definition: winuser.h:1686
#define WM_MOUSEMOVE
Definition: winuser.h:1775
#define HTCLIENT
Definition: winuser.h:2475
#define WM_SETCURSOR
Definition: winuser.h:1636

Definition at line 177 of file TrackMouseEvent.c.

Referenced by Test_TrackMouseEvent().

◆ mousehover3_chain

MSG_ENTRY mousehover3_chain[]
static
Initial value:

Definition at line 210 of file TrackMouseEvent.c.

Referenced by Test_TrackMouseEvent().

◆ mousehover3_dropmouse_chain

MSG_ENTRY mousehover3_dropmouse_chain[]
static
Initial value:

Definition at line 239 of file TrackMouseEvent.c.

Referenced by Test_TrackMouseEvent().

◆ mousehover3_dropmousell_chain

MSG_ENTRY mousehover3_dropmousell_chain[]
static
Initial value:

Definition at line 248 of file TrackMouseEvent.c.

Referenced by Test_TrackMouseEvent().

◆ mousehover3_droptimer_chain

MSG_ENTRY mousehover3_droptimer_chain[]
static
Initial value:

Definition at line 228 of file TrackMouseEvent.c.

Referenced by Test_TrackMouseEvent().

◆ mousehover3_nomove_chain

MSG_ENTRY mousehover3_nomove_chain[]
static
Initial value:
={
{0,0}}

Definition at line 222 of file TrackMouseEvent.c.

Referenced by Test_TrackMouseEvent().

◆ mouseleave2to1_chain

MSG_ENTRY mouseleave2to1_chain[]
static
Initial value:
={
{0,0}}
#define WM_MOUSELEAVE
Definition: commctrl.h:4975

Definition at line 189 of file TrackMouseEvent.c.

Referenced by Test_TrackMouseEvent().

◆ mouseleave2to3_chain

MSG_ENTRY mouseleave2to3_chain[]
static
Initial value:

Definition at line 199 of file TrackMouseEvent.c.

Referenced by Test_TrackMouseEvent().

◆ mouseleave3_remainging_chain

MSG_ENTRY mouseleave3_remainging_chain[]
static
Initial value:
={
{0,0}}

Definition at line 267 of file TrackMouseEvent.c.

Referenced by Test_TrackMouseEvent().

◆ mouseleave3to2_dropmouse_chain

MSG_ENTRY mouseleave3to2_dropmouse_chain[]
static
Initial value:

Definition at line 255 of file TrackMouseEvent.c.

Referenced by Test_TrackMouseEvent().

◆ mouseleave3to2_dropmousell_chain

MSG_ENTRY mouseleave3to2_dropmousell_chain[]
static
Initial value:
={
{0,0}}

Definition at line 262 of file TrackMouseEvent.c.

Referenced by Test_TrackMouseEvent().

◆ mousemove2_chain

MSG_ENTRY mousemove2_chain[]
static
Initial value:

Definition at line 167 of file TrackMouseEvent.c.

Referenced by Test_TrackMouseEvent().