2 * USER Input processing
4 * Copyright 1993 Bob Amstadt
5 * Copyright 1996 Albrecht Kleine
6 * Copyright 1997 David Faure
7 * Copyright 1998 Morten Welinder
8 * Copyright 1998 Ulrich Weigand
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include "wine/port.h"
35 #define NONAMELESSUNION
36 #define NONAMELESSSTRUCT
42 #include "wine/server.h"
43 #include "user_private.h"
45 #include "wine/debug.h"
48 WINE_DEFAULT_DEBUG_CHANNEL(key);
49 WINE_DECLARE_DEBUG_CHANNEL(keyboard);
52 /***********************************************************************
55 static WORD get_key_state(void)
59 if (GetSystemMetrics( SM_SWAPBUTTON ))
61 if (GetAsyncKeyState(VK_RBUTTON) & 0x80) ret |= MK_LBUTTON;
62 if (GetAsyncKeyState(VK_LBUTTON) & 0x80) ret |= MK_RBUTTON;
66 if (GetAsyncKeyState(VK_LBUTTON) & 0x80) ret |= MK_LBUTTON;
67 if (GetAsyncKeyState(VK_RBUTTON) & 0x80) ret |= MK_RBUTTON;
69 if (GetAsyncKeyState(VK_MBUTTON) & 0x80) ret |= MK_MBUTTON;
70 if (GetAsyncKeyState(VK_SHIFT) & 0x80) ret |= MK_SHIFT;
71 if (GetAsyncKeyState(VK_CONTROL) & 0x80) ret |= MK_CONTROL;
72 if (GetAsyncKeyState(VK_XBUTTON1) & 0x80) ret |= MK_XBUTTON1;
73 if (GetAsyncKeyState(VK_XBUTTON2) & 0x80) ret |= MK_XBUTTON2;
78 /***********************************************************************
79 * SendInput (USER32.@)
81 UINT WINAPI SendInput( UINT count, LPINPUT inputs, int size )
83 return USER_Driver->pSendInput( count, inputs, size );
87 /***********************************************************************
88 * keybd_event (USER32.@)
90 void WINAPI keybd_event( BYTE bVk, BYTE bScan,
91 DWORD dwFlags, ULONG_PTR dwExtraInfo )
95 input.type = INPUT_KEYBOARD;
97 input.u.ki.wScan = bScan;
98 input.u.ki.dwFlags = dwFlags;
99 input.u.ki.time = GetTickCount();
100 input.u.ki.dwExtraInfo = dwExtraInfo;
101 SendInput( 1, &input, sizeof(input) );
105 /***********************************************************************
106 * mouse_event (USER32.@)
108 void WINAPI mouse_event( DWORD dwFlags, DWORD dx, DWORD dy,
109 DWORD dwData, ULONG_PTR dwExtraInfo )
113 input.type = INPUT_MOUSE;
116 input.u.mi.mouseData = dwData;
117 input.u.mi.dwFlags = dwFlags;
118 input.u.mi.time = GetCurrentTime();
119 input.u.mi.dwExtraInfo = dwExtraInfo;
120 SendInput( 1, &input, sizeof(input) );
124 /***********************************************************************
125 * GetCursorPos (USER32.@)
127 BOOL WINAPI GetCursorPos( POINT *pt )
129 if (!pt) return FALSE;
130 return USER_Driver->pGetCursorPos( pt );
134 /***********************************************************************
135 * GetCursorInfo (USER32.@)
137 BOOL WINAPI GetCursorInfo( PCURSORINFO pci )
140 if (get_user_thread_info()->cursor_count >= 0) pci->flags = CURSOR_SHOWING;
142 GetCursorPos(&pci->ptScreenPos);
147 /***********************************************************************
148 * SetCursorPos (USER32.@)
150 BOOL WINAPI SetCursorPos( INT x, INT y )
152 return USER_Driver->pSetCursorPos( x, y );
156 /**********************************************************************
157 * SetCapture (USER32.@)
159 HWND WINAPI SetCapture( HWND hwnd )
163 SERVER_START_REQ( set_capture_window )
167 if (!wine_server_call_err( req ))
169 previous = reply->previous;
170 hwnd = reply->full_handle;
175 if (previous && previous != hwnd)
176 SendMessageW( previous, WM_CAPTURECHANGED, 0, (LPARAM)hwnd );
181 /**********************************************************************
182 * ReleaseCapture (USER32.@)
184 BOOL WINAPI ReleaseCapture(void)
189 SERVER_START_REQ( set_capture_window )
193 if ((ret = !wine_server_call_err( req ))) previous = reply->previous;
197 if (previous) SendMessageW( previous, WM_CAPTURECHANGED, 0, 0 );
202 /**********************************************************************
203 * GetCapture (USER32.@)
205 HWND WINAPI GetCapture(void)
209 SERVER_START_REQ( get_thread_input )
211 req->tid = GetCurrentThreadId();
212 if (!wine_server_call_err( req )) ret = reply->capture;
219 /**********************************************************************
220 * GetAsyncKeyState (USER32.@)
222 * Determine if a key is or was pressed. retval has high-order
223 * bit set to 1 if currently pressed, low-order bit set to 1 if key has
226 SHORT WINAPI GetAsyncKeyState(INT nKey)
228 return USER_Driver->pGetAsyncKeyState( nKey );
232 /***********************************************************************
233 * GetQueueStatus (USER32.@)
235 DWORD WINAPI GetQueueStatus( UINT flags )
240 FIXME("QS_xxxx flags (%04x) are not handled\n", flags & ~0xff);
242 /* check for pending X events */
243 USER_Driver->pMsgWaitForMultipleObjectsEx( 0, NULL, 0, QS_ALLINPUT, 0 );
245 SERVER_START_REQ( get_queue_status )
248 wine_server_call( req );
249 ret = MAKELONG( reply->changed_bits & flags, reply->wake_bits & flags );
256 /***********************************************************************
257 * GetInputState (USER32.@)
259 BOOL WINAPI GetInputState(void)
263 /* check for pending X events */
264 USER_Driver->pMsgWaitForMultipleObjectsEx( 0, NULL, 0, QS_INPUT, 0 );
266 SERVER_START_REQ( get_queue_status )
269 wine_server_call( req );
270 ret = reply->wake_bits & (QS_KEY | QS_MOUSEBUTTON);
277 /******************************************************************
278 * GetLastInputInfo (USER32.@)
280 BOOL WINAPI GetLastInputInfo(PLASTINPUTINFO plii)
286 if (plii->cbSize != sizeof (*plii) )
288 SetLastError(ERROR_INVALID_PARAMETER);
292 SERVER_START_REQ( get_last_input_time )
294 ret = !wine_server_call_err( req );
296 plii->dwTime = reply->time;
303 /**********************************************************************
304 * AttachThreadInput (USER32.@)
306 * Attaches the input processing mechanism of one thread to that of
309 BOOL WINAPI AttachThreadInput( DWORD from, DWORD to, BOOL attach )
313 SERVER_START_REQ( attach_thread_input )
315 req->tid_from = from;
317 req->attach = attach;
318 ret = !wine_server_call_err( req );
325 /**********************************************************************
326 * GetKeyState (USER32.@)
328 * An application calls the GetKeyState function in response to a
329 * keyboard-input message. This function retrieves the state of the key
330 * at the time the input message was generated.
332 SHORT WINAPI GetKeyState(INT vkey)
336 SERVER_START_REQ( get_key_state )
338 req->tid = GetCurrentThreadId();
340 if (!wine_server_call( req )) retval = (signed char)reply->state;
343 TRACE("key (0x%x) -> %x\n", vkey, retval);
348 /**********************************************************************
349 * GetKeyboardState (USER32.@)
351 BOOL WINAPI GetKeyboardState( LPBYTE state )
355 TRACE("(%p)\n", state);
357 memset( state, 0, 256 );
358 SERVER_START_REQ( get_key_state )
360 req->tid = GetCurrentThreadId();
362 wine_server_set_reply( req, state, 256 );
363 ret = !wine_server_call_err( req );
370 /**********************************************************************
371 * SetKeyboardState (USER32.@)
373 BOOL WINAPI SetKeyboardState( LPBYTE state )
377 TRACE("(%p)\n", state);
379 SERVER_START_REQ( set_key_state )
381 req->tid = GetCurrentThreadId();
382 wine_server_add_data( req, state, 256 );
383 ret = !wine_server_call_err( req );
390 /**********************************************************************
391 * VkKeyScanA (USER32.@)
393 * VkKeyScan translates an ANSI character to a virtual-key and shift code
394 * for the current keyboard.
395 * high-order byte yields :
399 * 3-5 Shift-key combinations that are not used for characters
402 * I.e. : Shift = 1, Ctrl = 2, Alt = 4.
403 * FIXME : works ok except for dead chars :
404 * VkKeyScan '^'(0x5e, 94) ... got keycode 00 ... returning 00
405 * VkKeyScan '`'(0x60, 96) ... got keycode 00 ... returning 00
407 SHORT WINAPI VkKeyScanA(CHAR cChar)
411 if (IsDBCSLeadByte(cChar)) return -1;
413 MultiByteToWideChar(CP_ACP, 0, &cChar, 1, &wChar, 1);
414 return VkKeyScanW(wChar);
417 /******************************************************************************
418 * VkKeyScanW (USER32.@)
420 SHORT WINAPI VkKeyScanW(WCHAR cChar)
422 return VkKeyScanExW(cChar, GetKeyboardLayout(0));
425 /**********************************************************************
426 * VkKeyScanExA (USER32.@)
428 WORD WINAPI VkKeyScanExA(CHAR cChar, HKL dwhkl)
432 if (IsDBCSLeadByte(cChar)) return -1;
434 MultiByteToWideChar(CP_ACP, 0, &cChar, 1, &wChar, 1);
435 return VkKeyScanExW(wChar, dwhkl);
438 /******************************************************************************
439 * VkKeyScanExW (USER32.@)
441 WORD WINAPI VkKeyScanExW(WCHAR cChar, HKL dwhkl)
443 return USER_Driver->pVkKeyScanEx(cChar, dwhkl);
446 /**********************************************************************
447 * OemKeyScan (USER32.@)
449 DWORD WINAPI OemKeyScan(WORD wOemChar)
451 TRACE("(%d)\n", wOemChar);
455 /******************************************************************************
456 * GetKeyboardType (USER32.@)
458 INT WINAPI GetKeyboardType(INT nTypeFlag)
460 TRACE_(keyboard)("(%d)\n", nTypeFlag);
463 case 0: /* Keyboard type */
464 return 4; /* AT-101 */
465 case 1: /* Keyboard Subtype */
466 return 0; /* There are no defined subtypes */
467 case 2: /* Number of F-keys */
468 return 12; /* We're doing an 101 for now, so return 12 F-keys */
470 WARN_(keyboard)("Unknown type\n");
471 return 0; /* The book says 0 here, so 0 */
475 /******************************************************************************
476 * MapVirtualKeyA (USER32.@)
478 UINT WINAPI MapVirtualKeyA(UINT code, UINT maptype)
480 return MapVirtualKeyExA( code, maptype, GetKeyboardLayout(0) );
483 /******************************************************************************
484 * MapVirtualKeyW (USER32.@)
486 UINT WINAPI MapVirtualKeyW(UINT code, UINT maptype)
488 return MapVirtualKeyExW(code, maptype, GetKeyboardLayout(0));
491 /******************************************************************************
492 * MapVirtualKeyExA (USER32.@)
494 UINT WINAPI MapVirtualKeyExA(UINT code, UINT maptype, HKL hkl)
496 return MapVirtualKeyExW(code, maptype, hkl);
499 /******************************************************************************
500 * MapVirtualKeyExW (USER32.@)
502 UINT WINAPI MapVirtualKeyExW(UINT code, UINT maptype, HKL hkl)
504 TRACE_(keyboard)("(%d, %d, %p)\n", code, maptype, hkl);
506 return USER_Driver->pMapVirtualKeyEx(code, maptype, hkl);
509 /****************************************************************************
510 * GetKBCodePage (USER32.@)
512 UINT WINAPI GetKBCodePage(void)
517 /***********************************************************************
518 * GetKeyboardLayout (USER32.@)
520 * - device handle for keyboard layout defaulted to
521 * the language id. This is the way Windows default works.
522 * - the thread identifier (dwLayout) is also ignored.
524 HKL WINAPI GetKeyboardLayout(DWORD dwLayout)
526 return USER_Driver->pGetKeyboardLayout(dwLayout);
529 /****************************************************************************
530 * GetKeyboardLayoutNameA (USER32.@)
532 BOOL WINAPI GetKeyboardLayoutNameA(LPSTR pszKLID)
534 WCHAR buf[KL_NAMELENGTH];
536 if (GetKeyboardLayoutNameW(buf))
537 return WideCharToMultiByte( CP_ACP, 0, buf, -1, pszKLID, KL_NAMELENGTH, NULL, NULL ) != 0;
541 /****************************************************************************
542 * GetKeyboardLayoutNameW (USER32.@)
544 BOOL WINAPI GetKeyboardLayoutNameW(LPWSTR pwszKLID)
546 return USER_Driver->pGetKeyboardLayoutName(pwszKLID);
549 /****************************************************************************
550 * GetKeyNameTextA (USER32.@)
552 INT WINAPI GetKeyNameTextA(LONG lParam, LPSTR lpBuffer, INT nSize)
557 if (!GetKeyNameTextW(lParam, buf, 256))
559 ret = WideCharToMultiByte(CP_ACP, 0, buf, -1, lpBuffer, nSize, NULL, NULL);
568 /****************************************************************************
569 * GetKeyNameTextW (USER32.@)
571 INT WINAPI GetKeyNameTextW(LONG lParam, LPWSTR lpBuffer, INT nSize)
573 return USER_Driver->pGetKeyNameText( lParam, lpBuffer, nSize );
576 /****************************************************************************
577 * ToUnicode (USER32.@)
579 INT WINAPI ToUnicode(UINT virtKey, UINT scanCode, LPBYTE lpKeyState,
580 LPWSTR lpwStr, int size, UINT flags)
582 return ToUnicodeEx(virtKey, scanCode, lpKeyState, lpwStr, size, flags, GetKeyboardLayout(0));
585 /****************************************************************************
586 * ToUnicodeEx (USER32.@)
588 INT WINAPI ToUnicodeEx(UINT virtKey, UINT scanCode, LPBYTE lpKeyState,
589 LPWSTR lpwStr, int size, UINT flags, HKL hkl)
591 return USER_Driver->pToUnicodeEx(virtKey, scanCode, lpKeyState, lpwStr, size, flags, hkl);
594 /****************************************************************************
597 INT WINAPI ToAscii( UINT virtKey, UINT scanCode, LPBYTE lpKeyState,
598 LPWORD lpChar, UINT flags )
600 return ToAsciiEx(virtKey, scanCode, lpKeyState, lpChar, flags, GetKeyboardLayout(0));
603 /****************************************************************************
604 * ToAsciiEx (USER32.@)
606 INT WINAPI ToAsciiEx( UINT virtKey, UINT scanCode, LPBYTE lpKeyState,
607 LPWORD lpChar, UINT flags, HKL dwhkl )
612 ret = ToUnicodeEx(virtKey, scanCode, lpKeyState, uni_chars, 2, flags, dwhkl);
613 if (ret < 0) n_ret = 1; /* FIXME: make ToUnicode return 2 for dead chars */
615 WideCharToMultiByte(CP_ACP, 0, uni_chars, n_ret, (LPSTR)lpChar, 2, NULL, NULL);
619 /**********************************************************************
620 * ActivateKeyboardLayout (USER32.@)
622 HKL WINAPI ActivateKeyboardLayout(HKL hLayout, UINT flags)
624 TRACE_(keyboard)("(%p, %d)\n", hLayout, flags);
626 return USER_Driver->pActivateKeyboardLayout(hLayout, flags);
630 /***********************************************************************
631 * GetKeyboardLayoutList (USER32.@)
633 * Return number of values available if either input parm is
634 * 0, per MS documentation.
636 UINT WINAPI GetKeyboardLayoutList(INT nBuff, HKL *layouts)
638 TRACE_(keyboard)("(%d,%p)\n",nBuff,layouts);
640 return USER_Driver->pGetKeyboardLayoutList(nBuff, layouts);
644 /***********************************************************************
645 * RegisterHotKey (USER32.@)
647 BOOL WINAPI RegisterHotKey(HWND hwnd,INT id,UINT modifiers,UINT vk)
649 FIXME_(keyboard)("(%p,%d,0x%08x,%d): stub\n",hwnd,id,modifiers,vk);
653 /***********************************************************************
654 * UnregisterHotKey (USER32.@)
656 BOOL WINAPI UnregisterHotKey(HWND hwnd,INT id)
658 FIXME_(keyboard)("(%p,%d): stub\n",hwnd,id);
662 /***********************************************************************
663 * LoadKeyboardLayoutW (USER32.@)
665 HKL WINAPI LoadKeyboardLayoutW(LPCWSTR pwszKLID, UINT Flags)
667 TRACE_(keyboard)("(%s, %d)\n", debugstr_w(pwszKLID), Flags);
669 return USER_Driver->pLoadKeyboardLayout(pwszKLID, Flags);
672 /***********************************************************************
673 * LoadKeyboardLayoutA (USER32.@)
675 HKL WINAPI LoadKeyboardLayoutA(LPCSTR pwszKLID, UINT Flags)
678 UNICODE_STRING pwszKLIDW;
680 if (pwszKLID) RtlCreateUnicodeStringFromAsciiz(&pwszKLIDW, pwszKLID);
681 else pwszKLIDW.Buffer = NULL;
683 ret = LoadKeyboardLayoutW(pwszKLIDW.Buffer, Flags);
684 RtlFreeUnicodeString(&pwszKLIDW);
689 /***********************************************************************
690 * UnloadKeyboardLayout (USER32.@)
692 BOOL WINAPI UnloadKeyboardLayout(HKL hkl)
694 TRACE_(keyboard)("(%p)\n", hkl);
696 return USER_Driver->pUnloadKeyboardLayout(hkl);
699 typedef struct __TRACKINGLIST {
701 POINT pos; /* center of hover rectangle */
702 INT iHoverTime; /* elapsed time the cursor has been inside of the hover rect */
705 static _TRACKINGLIST TrackingList[10];
706 static int iTrackMax = 0;
707 static UINT_PTR timer;
708 static const INT iTimerInterval = 50; /* msec for timer interval */
710 static void CALLBACK TrackMouseEventProc(HWND hwndUnused, UINT uMsg, UINT_PTR idEvent,
718 INT hoverwidth = 0, hoverheight = 0;
722 hwnd = WindowFromPoint(pos);
724 SystemParametersInfoA(SPI_GETMOUSEHOVERWIDTH, 0, &hoverwidth, 0);
725 SystemParametersInfoA(SPI_GETMOUSEHOVERHEIGHT, 0, &hoverheight, 0);
727 /* loop through tracking events we are processing */
728 while (i < iTrackMax) {
729 if (TrackingList[i].tme.dwFlags & TME_NONCLIENT) {
736 /* see if this tracking event is looking for TME_LEAVE and that the */
737 /* mouse has left the window */
738 if (TrackingList[i].tme.dwFlags & TME_LEAVE) {
739 if (TrackingList[i].tme.hwndTrack != hwnd) {
741 PostMessageA(TrackingList[i].tme.hwndTrack, WM_NCMOUSELEAVE, 0, 0);
744 PostMessageA(TrackingList[i].tme.hwndTrack, WM_MOUSELEAVE, 0, 0);
747 /* remove the TME_LEAVE flag */
748 TrackingList[i].tme.dwFlags ^= TME_LEAVE;
751 GetClientRect(hwnd, &client);
752 MapWindowPoints(hwnd, NULL, (LPPOINT)&client, 2);
753 if(PtInRect(&client, pos)) {
755 PostMessageA(TrackingList[i].tme.hwndTrack, WM_NCMOUSELEAVE, 0, 0);
756 /* remove the TME_LEAVE flag */
757 TrackingList[i].tme.dwFlags ^= TME_LEAVE;
762 PostMessageA(TrackingList[i].tme.hwndTrack, WM_MOUSELEAVE, 0, 0);
763 /* remove the TME_LEAVE flag */
764 TrackingList[i].tme.dwFlags ^= TME_LEAVE;
770 /* see if we are tracking hovering for this hwnd */
771 if(TrackingList[i].tme.dwFlags & TME_HOVER) {
772 /* add the timer interval to the hovering time */
773 TrackingList[i].iHoverTime+=iTimerInterval;
775 /* has the cursor moved outside the rectangle centered around pos? */
776 if((abs(pos.x - TrackingList[i].pos.x) > (hoverwidth / 2.0))
777 || (abs(pos.y - TrackingList[i].pos.y) > (hoverheight / 2.0)))
779 /* record this new position as the current position and reset */
780 /* the iHoverTime variable to 0 */
781 TrackingList[i].pos = pos;
782 TrackingList[i].iHoverTime = 0;
785 /* has the mouse hovered long enough? */
786 if(TrackingList[i].iHoverTime <= TrackingList[i].tme.dwHoverTime)
790 ScreenToClient(hwnd, &posClient);
792 PostMessageW(TrackingList[i].tme.hwndTrack, WM_NCMOUSEHOVER,
793 get_key_state(), MAKELPARAM( posClient.x, posClient.y ));
796 PostMessageW(TrackingList[i].tme.hwndTrack, WM_MOUSEHOVER,
797 get_key_state(), MAKELPARAM( posClient.x, posClient.y ));
800 /* stop tracking mouse hover */
801 TrackingList[i].tme.dwFlags ^= TME_HOVER;
805 /* see if we are still tracking TME_HOVER or TME_LEAVE for this entry */
806 if((TrackingList[i].tme.dwFlags & TME_HOVER) ||
807 (TrackingList[i].tme.dwFlags & TME_LEAVE)) {
809 } else { /* remove this entry from the tracking list */
810 TrackingList[i] = TrackingList[--iTrackMax];
814 /* stop the timer if the tracking list is empty */
822 /***********************************************************************
823 * TrackMouseEvent [USER32]
825 * Requests notification of mouse events
827 * During mouse tracking WM_MOUSEHOVER or WM_MOUSELEAVE events are posted
828 * to the hwnd specified in the ptme structure. After the event message
829 * is posted to the hwnd, the entry in the queue is removed.
831 * If the current hwnd isn't ptme->hwndTrack the TME_HOVER flag is completely
832 * ignored. The TME_LEAVE flag results in a WM_MOUSELEAVE message being posted
833 * immediately and the TME_LEAVE flag being ignored.
836 * ptme [I,O] pointer to TRACKMOUSEEVENT information structure.
845 TrackMouseEvent (TRACKMOUSEEVENT *ptme)
849 BOOL cancel = 0, hover = 0, leave = 0, query = 0, nonclient = 0, inclient = 0;
857 SetRectEmpty(&client);
859 TRACE("%lx, %lx, %p, %lx\n", ptme->cbSize, ptme->dwFlags, ptme->hwndTrack, ptme->dwHoverTime);
861 if (ptme->cbSize != sizeof(TRACKMOUSEEVENT)) {
862 WARN("wrong TRACKMOUSEEVENT size from app\n");
863 SetLastError(ERROR_INVALID_PARAMETER); /* FIXME not sure if this is correct */
867 flags = ptme->dwFlags;
869 /* if HOVER_DEFAULT was specified replace this with the systems current value */
870 if(ptme->dwHoverTime == HOVER_DEFAULT)
871 SystemParametersInfoA(SPI_GETMOUSEHOVERTIME, 0, &(ptme->dwHoverTime), 0);
874 hwnd = WindowFromPoint(pos);
876 if ( flags & TME_CANCEL ) {
877 flags &= ~ TME_CANCEL;
881 if ( flags & TME_HOVER ) {
882 flags &= ~ TME_HOVER;
886 if ( flags & TME_LEAVE ) {
887 flags &= ~ TME_LEAVE;
891 if ( flags & TME_NONCLIENT ) {
892 flags &= ~ TME_NONCLIENT;
896 /* fill the TRACKMOUSEEVENT struct with the current tracking for the given hwnd */
897 if ( flags & TME_QUERY ) {
898 flags &= ~ TME_QUERY;
902 /* Find the tracking list entry with the matching hwnd */
903 while((i < iTrackMax) && (TrackingList[i].tme.hwndTrack != ptme->hwndTrack)) {
907 /* hwnd found, fill in the ptme struct */
909 *ptme = TrackingList[i].tme;
913 return TRUE; /* return here, TME_QUERY is retrieving information */
917 FIXME("Unknown flag(s) %08lx\n", flags );
920 /* find a matching hwnd if one exists */
923 while((i < iTrackMax) && (TrackingList[i].tme.hwndTrack != ptme->hwndTrack)) {
928 TrackingList[i].tme.dwFlags &= ~(ptme->dwFlags & ~TME_CANCEL);
930 /* if we aren't tracking on hover or leave remove this entry */
931 if(!((TrackingList[i].tme.dwFlags & TME_HOVER) ||
932 (TrackingList[i].tme.dwFlags & TME_LEAVE)))
934 TrackingList[i] = TrackingList[--iTrackMax];
943 /* see if hwndTrack isn't the current window */
944 if(ptme->hwndTrack != hwnd) {
947 PostMessageA(ptme->hwndTrack, WM_NCMOUSELEAVE, 0, 0);
950 PostMessageA(ptme->hwndTrack, WM_MOUSELEAVE, 0, 0);
954 GetClientRect(ptme->hwndTrack, &client);
955 MapWindowPoints(ptme->hwndTrack, NULL, (LPPOINT)&client, 2);
956 if(PtInRect(&client, pos)) {
959 if(nonclient && inclient) {
960 PostMessageA(ptme->hwndTrack, WM_NCMOUSELEAVE, 0, 0);
963 else if(!nonclient && !inclient) {
964 PostMessageA(ptme->hwndTrack, WM_MOUSELEAVE, 0, 0);
968 /* See if this hwnd is already being tracked and update the tracking flags */
969 for(i = 0; i < iTrackMax; i++) {
970 if(TrackingList[i].tme.hwndTrack == ptme->hwndTrack) {
971 TrackingList[i].tme.dwFlags = 0;
974 TrackingList[i].tme.dwFlags |= TME_HOVER;
975 TrackingList[i].tme.dwHoverTime = ptme->dwHoverTime;
979 TrackingList[i].tme.dwFlags |= TME_LEAVE;
982 TrackingList[i].tme.dwFlags |= TME_NONCLIENT;
984 /* reset iHoverTime as per winapi specs */
985 TrackingList[i].iHoverTime = 0;
991 /* if the tracking list is full return FALSE */
992 if (iTrackMax == sizeof (TrackingList) / sizeof(*TrackingList)) {
996 /* Adding new mouse event to the tracking list */
997 TrackingList[iTrackMax].tme = *ptme;
999 /* Initialize HoverInfo variables even if not hover tracking */
1000 TrackingList[iTrackMax].iHoverTime = 0;
1001 TrackingList[iTrackMax].pos = pos;
1006 timer = SetTimer(0, 0, iTimerInterval, TrackMouseEventProc);