1998-11-08 13:26:36 +01:00
|
|
|
/*
|
|
|
|
* USER Input processing
|
|
|
|
*
|
|
|
|
* Copyright 1993 Bob Amstadt
|
2002-06-01 01:06:46 +02:00
|
|
|
* Copyright 1996 Albrecht Kleine
|
1998-11-08 13:26:36 +01:00
|
|
|
* Copyright 1997 David Faure
|
|
|
|
* Copyright 1998 Morten Welinder
|
|
|
|
* Copyright 1998 Ulrich Weigand
|
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
|
|
|
|
2003-11-26 23:29:30 +01:00
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2000-02-10 20:03:02 +01:00
|
|
|
#include <stdio.h>
|
1998-11-08 13:26:36 +01:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
2003-01-07 21:36:20 +01:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
2000-02-10 20:03:02 +01:00
|
|
|
#include "windef.h"
|
2000-12-19 05:53:20 +01:00
|
|
|
#include "winbase.h"
|
2000-02-10 20:03:02 +01:00
|
|
|
#include "wingdi.h"
|
1999-02-22 11:16:00 +01:00
|
|
|
#include "winuser.h"
|
2003-08-20 20:22:31 +02:00
|
|
|
#include "winnls.h"
|
2001-07-19 02:39:09 +02:00
|
|
|
#include "wine/server.h"
|
1998-11-08 13:26:36 +01:00
|
|
|
#include "message.h"
|
2004-12-08 19:06:14 +01:00
|
|
|
#include "user_private.h"
|
2002-11-18 20:47:20 +01:00
|
|
|
#include "winternl.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1998-11-08 13:26:36 +01:00
|
|
|
#include "winerror.h"
|
|
|
|
|
2005-03-09 17:45:23 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(key);
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(keyboard);
|
1998-11-08 13:26:36 +01:00
|
|
|
|
2001-06-19 21:16:41 +02:00
|
|
|
|
2001-10-18 23:38:59 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* get_key_state
|
|
|
|
*/
|
|
|
|
static WORD get_key_state(void)
|
|
|
|
{
|
|
|
|
WORD ret = 0;
|
|
|
|
|
2005-03-09 12:51:31 +01:00
|
|
|
if (GetSystemMetrics( SM_SWAPBUTTON ))
|
2001-10-18 23:38:59 +02:00
|
|
|
{
|
2005-03-09 17:45:23 +01:00
|
|
|
if (GetAsyncKeyState(VK_RBUTTON) & 0x80) ret |= MK_LBUTTON;
|
|
|
|
if (GetAsyncKeyState(VK_LBUTTON) & 0x80) ret |= MK_RBUTTON;
|
2001-10-18 23:38:59 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-03-09 17:45:23 +01:00
|
|
|
if (GetAsyncKeyState(VK_LBUTTON) & 0x80) ret |= MK_LBUTTON;
|
|
|
|
if (GetAsyncKeyState(VK_RBUTTON) & 0x80) ret |= MK_RBUTTON;
|
2001-10-18 23:38:59 +02:00
|
|
|
}
|
2005-03-09 17:45:23 +01:00
|
|
|
if (GetAsyncKeyState(VK_MBUTTON) & 0x80) ret |= MK_MBUTTON;
|
|
|
|
if (GetAsyncKeyState(VK_SHIFT) & 0x80) ret |= MK_SHIFT;
|
|
|
|
if (GetAsyncKeyState(VK_CONTROL) & 0x80) ret |= MK_CONTROL;
|
|
|
|
if (GetAsyncKeyState(VK_XBUTTON1) & 0x80) ret |= MK_XBUTTON1;
|
|
|
|
if (GetAsyncKeyState(VK_XBUTTON2) & 0x80) ret |= MK_XBUTTON2;
|
2001-10-18 23:38:59 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-25 22:01:03 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SendInput (USER32.@)
|
|
|
|
*/
|
|
|
|
UINT WINAPI SendInput( UINT count, LPINPUT inputs, int size )
|
|
|
|
{
|
2005-03-09 17:45:23 +01:00
|
|
|
if (USER_Driver.pSendInput) return USER_Driver.pSendInput( count, inputs, size );
|
|
|
|
return 0;
|
2001-06-25 22:01:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* keybd_event (USER32.@)
|
|
|
|
*/
|
|
|
|
void WINAPI keybd_event( BYTE bVk, BYTE bScan,
|
2002-10-31 02:04:39 +01:00
|
|
|
DWORD dwFlags, ULONG_PTR dwExtraInfo )
|
2001-06-25 22:01:03 +02:00
|
|
|
{
|
|
|
|
INPUT input;
|
|
|
|
|
|
|
|
input.type = INPUT_KEYBOARD;
|
|
|
|
input.u.ki.wVk = bVk;
|
|
|
|
input.u.ki.wScan = bScan;
|
|
|
|
input.u.ki.dwFlags = dwFlags;
|
2001-10-17 19:50:02 +02:00
|
|
|
input.u.ki.time = GetTickCount();
|
|
|
|
input.u.ki.dwExtraInfo = dwExtraInfo;
|
2001-06-25 22:01:03 +02:00
|
|
|
SendInput( 1, &input, sizeof(input) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
/***********************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* mouse_event (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
|
|
|
void WINAPI mouse_event( DWORD dwFlags, DWORD dx, DWORD dy,
|
2002-10-31 02:04:39 +01:00
|
|
|
DWORD dwData, ULONG_PTR dwExtraInfo )
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2001-06-25 22:01:03 +02:00
|
|
|
INPUT input;
|
|
|
|
|
|
|
|
input.type = INPUT_MOUSE;
|
|
|
|
input.u.mi.dx = dx;
|
|
|
|
input.u.mi.dy = dy;
|
|
|
|
input.u.mi.mouseData = dwData;
|
|
|
|
input.u.mi.dwFlags = dwFlags;
|
2001-10-18 23:38:59 +02:00
|
|
|
input.u.mi.time = GetCurrentTime();
|
|
|
|
input.u.mi.dwExtraInfo = dwExtraInfo;
|
|
|
|
SendInput( 1, &input, sizeof(input) );
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
2001-06-25 22:01:03 +02:00
|
|
|
|
2000-12-16 21:37:16 +01:00
|
|
|
/***********************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* GetCursorPos (USER32.@)
|
2000-12-16 21:37:16 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI GetCursorPos( POINT *pt )
|
|
|
|
{
|
2005-03-09 17:45:23 +01:00
|
|
|
if (pt && USER_Driver.pGetCursorPos) return USER_Driver.pGetCursorPos( pt );
|
|
|
|
return FALSE;
|
2000-12-16 21:37:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-29 01:38:10 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* GetCursorInfo (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetCursorInfo( PCURSORINFO pci )
|
|
|
|
{
|
2002-08-30 01:59:17 +02:00
|
|
|
MESSAGEQUEUE *queue = QUEUE_Current();
|
|
|
|
|
2002-08-29 01:38:10 +02:00
|
|
|
if (!pci) return 0;
|
2002-08-30 01:59:17 +02:00
|
|
|
if (queue->cursor_count >= 0) pci->flags = CURSOR_SHOWING;
|
|
|
|
else pci->flags = 0;
|
2002-08-29 01:38:10 +02:00
|
|
|
GetCursorPos(&pci->ptScreenPos);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-21 02:44:09 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetCursorPos (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetCursorPos( INT x, INT y )
|
|
|
|
{
|
2005-03-09 17:45:23 +01:00
|
|
|
if (USER_Driver.pSetCursorPos) return USER_Driver.pSetCursorPos( x, y );
|
|
|
|
return FALSE;
|
2001-06-21 02:44:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
/**********************************************************************
|
2002-10-12 03:24:37 +02:00
|
|
|
* SetCapture (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
2002-10-12 03:24:37 +02:00
|
|
|
HWND WINAPI SetCapture( HWND hwnd )
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2002-10-12 03:24:37 +02:00
|
|
|
HWND previous = 0;
|
1999-02-05 11:37:53 +01:00
|
|
|
|
2002-10-12 03:24:37 +02:00
|
|
|
SERVER_START_REQ( set_capture_window )
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2002-10-12 03:24:37 +02:00
|
|
|
req->handle = hwnd;
|
|
|
|
req->flags = 0;
|
|
|
|
if (!wine_server_call_err( req ))
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2002-10-12 03:24:37 +02:00
|
|
|
previous = reply->previous;
|
|
|
|
hwnd = reply->full_handle;
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
}
|
2002-10-12 03:24:37 +02:00
|
|
|
SERVER_END_REQ;
|
1998-11-08 13:26:36 +01:00
|
|
|
|
2002-10-12 03:24:37 +02:00
|
|
|
if (previous && previous != hwnd)
|
|
|
|
SendMessageW( previous, WM_CAPTURECHANGED, 0, (LPARAM)hwnd );
|
|
|
|
return previous;
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* ReleaseCapture (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-04-15 18:40:16 +02:00
|
|
|
BOOL WINAPI ReleaseCapture(void)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2002-10-12 03:24:37 +02:00
|
|
|
return (SetCapture(0) != 0);
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* GetCapture (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HWND WINAPI GetCapture(void)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2002-10-12 03:24:37 +02:00
|
|
|
HWND ret = 0;
|
|
|
|
|
|
|
|
SERVER_START_REQ( get_thread_input )
|
|
|
|
{
|
|
|
|
req->tid = GetCurrentThreadId();
|
|
|
|
if (!wine_server_call_err( req )) ret = reply->capture;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
2002-10-12 03:24:37 +02:00
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
/**********************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* GetAsyncKeyState (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*
|
2002-06-01 01:06:46 +02:00
|
|
|
* Determine if a key is or was pressed. retval has high-order
|
1998-11-08 13:26:36 +01:00
|
|
|
* bit set to 1 if currently pressed, low-order bit set to 1 if key has
|
|
|
|
* been pressed.
|
|
|
|
*/
|
2002-02-22 22:24:25 +01:00
|
|
|
SHORT WINAPI GetAsyncKeyState(INT nKey)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2005-03-09 17:45:23 +01:00
|
|
|
if (USER_Driver.pGetAsyncKeyState) return USER_Driver.pGetAsyncKeyState( nKey );
|
|
|
|
return 0;
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
1999-05-22 21:00:27 +02:00
|
|
|
|
2005-04-26 10:18:47 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* GetQueueStatus (USER32.@)
|
|
|
|
*/
|
|
|
|
DWORD WINAPI GetQueueStatus( UINT flags )
|
|
|
|
{
|
|
|
|
DWORD ret = 0;
|
|
|
|
|
|
|
|
/* check for pending X events */
|
|
|
|
if (USER_Driver.pMsgWaitForMultipleObjectsEx)
|
|
|
|
USER_Driver.pMsgWaitForMultipleObjectsEx( 0, NULL, 0, QS_ALLINPUT, 0 );
|
|
|
|
|
|
|
|
SERVER_START_REQ( get_queue_status )
|
|
|
|
{
|
|
|
|
req->clear = 1;
|
|
|
|
wine_server_call( req );
|
|
|
|
ret = MAKELONG( reply->changed_bits & flags, reply->wake_bits & flags );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetInputState (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetInputState(void)
|
|
|
|
{
|
|
|
|
DWORD ret = 0;
|
|
|
|
|
|
|
|
/* check for pending X events */
|
|
|
|
if (USER_Driver.pMsgWaitForMultipleObjectsEx)
|
|
|
|
USER_Driver.pMsgWaitForMultipleObjectsEx( 0, NULL, 0, QS_INPUT, 0 );
|
|
|
|
|
|
|
|
SERVER_START_REQ( get_queue_status )
|
|
|
|
{
|
|
|
|
req->clear = 0;
|
|
|
|
wine_server_call( req );
|
|
|
|
ret = reply->wake_bits & (QS_KEY | QS_MOUSEBUTTON);
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* AttachThreadInput (USER32.@)
|
|
|
|
*
|
|
|
|
* Attaches the input processing mechanism of one thread to that of
|
|
|
|
* another thread.
|
|
|
|
*/
|
|
|
|
BOOL WINAPI AttachThreadInput( DWORD from, DWORD to, BOOL attach )
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
SERVER_START_REQ( attach_thread_input )
|
|
|
|
{
|
|
|
|
req->tid_from = from;
|
|
|
|
req->tid_to = to;
|
|
|
|
req->attach = attach;
|
|
|
|
ret = !wine_server_call_err( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* GetKeyState (USER32.@)
|
|
|
|
*
|
|
|
|
* An application calls the GetKeyState function in response to a
|
|
|
|
* keyboard-input message. This function retrieves the state of the key
|
|
|
|
* at the time the input message was generated.
|
|
|
|
*/
|
|
|
|
SHORT WINAPI GetKeyState(INT vkey)
|
|
|
|
{
|
|
|
|
SHORT retval = 0;
|
|
|
|
|
|
|
|
SERVER_START_REQ( get_key_state )
|
|
|
|
{
|
|
|
|
req->tid = GetCurrentThreadId();
|
|
|
|
req->key = vkey;
|
|
|
|
if (!wine_server_call( req )) retval = (signed char)reply->state;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
TRACE("key (0x%x) -> %x\n", vkey, retval);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* GetKeyboardState (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetKeyboardState( LPBYTE state )
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", state);
|
|
|
|
|
|
|
|
memset( state, 0, 256 );
|
|
|
|
SERVER_START_REQ( get_key_state )
|
|
|
|
{
|
|
|
|
req->tid = GetCurrentThreadId();
|
|
|
|
req->key = -1;
|
|
|
|
wine_server_set_reply( req, state, 256 );
|
|
|
|
ret = !wine_server_call_err( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* SetKeyboardState (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetKeyboardState( LPBYTE state )
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", state);
|
|
|
|
|
|
|
|
SERVER_START_REQ( set_key_state )
|
|
|
|
{
|
|
|
|
req->tid = GetCurrentThreadId();
|
|
|
|
wine_server_add_data( req, state, 256 );
|
|
|
|
ret = !wine_server_call_err( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
/**********************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* VkKeyScanA (USER32.@)
|
2001-10-17 19:50:02 +02:00
|
|
|
*
|
|
|
|
* VkKeyScan translates an ANSI character to a virtual-key and shift code
|
|
|
|
* for the current keyboard.
|
|
|
|
* high-order byte yields :
|
|
|
|
* 0 Unshifted
|
|
|
|
* 1 Shift
|
|
|
|
* 2 Ctrl
|
|
|
|
* 3-5 Shift-key combinations that are not used for characters
|
|
|
|
* 6 Ctrl-Alt
|
|
|
|
* 7 Ctrl-Alt-Shift
|
|
|
|
* I.e. : Shift = 1, Ctrl = 2, Alt = 4.
|
|
|
|
* FIXME : works ok except for dead chars :
|
|
|
|
* VkKeyScan '^'(0x5e, 94) ... got keycode 00 ... returning 00
|
|
|
|
* VkKeyScan '`'(0x60, 96) ... got keycode 00 ... returning 00
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
2003-11-14 04:32:43 +01:00
|
|
|
SHORT WINAPI VkKeyScanA(CHAR cChar)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
WCHAR wChar;
|
|
|
|
|
|
|
|
if (IsDBCSLeadByte(cChar)) return -1;
|
|
|
|
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, &cChar, 1, &wChar, 1);
|
|
|
|
return VkKeyScanW(wChar);
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* VkKeyScanW (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
2003-11-14 04:32:43 +01:00
|
|
|
SHORT WINAPI VkKeyScanW(WCHAR cChar)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
return VkKeyScanExW(cChar, GetKeyboardLayout(0));
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
1999-03-28 15:15:40 +02:00
|
|
|
/**********************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* VkKeyScanExA (USER32.@)
|
1999-03-28 15:15:40 +02:00
|
|
|
*/
|
|
|
|
WORD WINAPI VkKeyScanExA(CHAR cChar, HKL dwhkl)
|
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
WCHAR wChar;
|
|
|
|
|
|
|
|
if (IsDBCSLeadByte(cChar)) return -1;
|
|
|
|
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, &cChar, 1, &wChar, 1);
|
|
|
|
return VkKeyScanExW(wChar, dwhkl);
|
1999-03-28 15:15:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* VkKeyScanExW (USER32.@)
|
1999-03-28 15:15:40 +02:00
|
|
|
*/
|
|
|
|
WORD WINAPI VkKeyScanExW(WCHAR cChar, HKL dwhkl)
|
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
if (USER_Driver.pVkKeyScanEx)
|
|
|
|
return USER_Driver.pVkKeyScanEx(cChar, dwhkl);
|
|
|
|
return -1;
|
1999-03-28 15:15:40 +02:00
|
|
|
}
|
2001-10-17 19:50:02 +02:00
|
|
|
|
2004-09-02 00:47:48 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* OemKeyScan (USER32.@)
|
|
|
|
*/
|
|
|
|
DWORD WINAPI OemKeyScan(WORD wOemChar)
|
|
|
|
{
|
|
|
|
TRACE("(%d)\n", wOemChar);
|
|
|
|
return wOemChar;
|
|
|
|
}
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
/******************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* GetKeyboardType (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
INT WINAPI GetKeyboardType(INT nTypeFlag)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2001-10-17 19:50:02 +02:00
|
|
|
TRACE_(keyboard)("(%d)\n", nTypeFlag);
|
|
|
|
switch(nTypeFlag)
|
|
|
|
{
|
|
|
|
case 0: /* Keyboard type */
|
|
|
|
return 4; /* AT-101 */
|
|
|
|
case 1: /* Keyboard Subtype */
|
|
|
|
return 0; /* There are no defined subtypes */
|
|
|
|
case 2: /* Number of F-keys */
|
|
|
|
return 12; /* We're doing an 101 for now, so return 12 F-keys */
|
|
|
|
default:
|
|
|
|
WARN_(keyboard)("Unknown type\n");
|
|
|
|
return 0; /* The book says 0 here, so 0 */
|
|
|
|
}
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* MapVirtualKeyA (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
UINT WINAPI MapVirtualKeyA(UINT code, UINT maptype)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
return MapVirtualKeyExA( code, maptype, GetKeyboardLayout(0) );
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* MapVirtualKeyW (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
UINT WINAPI MapVirtualKeyW(UINT code, UINT maptype)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
return MapVirtualKeyExW(code, maptype, GetKeyboardLayout(0));
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
1999-02-13 09:53:22 +01:00
|
|
|
/******************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* MapVirtualKeyExA (USER32.@)
|
1999-02-13 09:53:22 +01:00
|
|
|
*/
|
2000-03-28 21:31:18 +02:00
|
|
|
UINT WINAPI MapVirtualKeyExA(UINT code, UINT maptype, HKL hkl)
|
1999-02-13 09:53:22 +01:00
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
return MapVirtualKeyExW(code, maptype, hkl);
|
1999-02-13 09:53:22 +01:00
|
|
|
}
|
|
|
|
|
2000-12-05 04:56:56 +01:00
|
|
|
/******************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* MapVirtualKeyExW (USER32.@)
|
2000-12-05 04:56:56 +01:00
|
|
|
*/
|
|
|
|
UINT WINAPI MapVirtualKeyExW(UINT code, UINT maptype, HKL hkl)
|
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
TRACE_(keyboard)("(%d, %d, %p)\n", code, maptype, hkl);
|
|
|
|
|
|
|
|
if (USER_Driver.pMapVirtualKeyEx)
|
|
|
|
return USER_Driver.pMapVirtualKeyEx(code, maptype, hkl);
|
|
|
|
return 0;
|
2000-12-05 04:56:56 +01:00
|
|
|
}
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
/****************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* GetKBCodePage (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
UINT WINAPI GetKBCodePage(void)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2000-12-29 20:47:53 +01:00
|
|
|
return GetOEMCP();
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
1999-02-28 12:13:16 +01:00
|
|
|
/***********************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* GetKeyboardLayout (USER32.@)
|
1999-02-28 12:13:16 +01:00
|
|
|
*
|
2003-11-14 04:32:43 +01:00
|
|
|
* - device handle for keyboard layout defaulted to
|
1999-02-28 12:13:16 +01:00
|
|
|
* the language id. This is the way Windows default works.
|
|
|
|
* - the thread identifier (dwLayout) is also ignored.
|
|
|
|
*/
|
|
|
|
HKL WINAPI GetKeyboardLayout(DWORD dwLayout)
|
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
if (USER_Driver.pGetKeyboardLayout)
|
|
|
|
return USER_Driver.pGetKeyboardLayout(dwLayout);
|
|
|
|
return 0;
|
1999-02-28 12:13:16 +01:00
|
|
|
}
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
/****************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* GetKeyboardLayoutNameA (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
2003-11-14 04:32:43 +01:00
|
|
|
BOOL WINAPI GetKeyboardLayoutNameA(LPSTR pszKLID)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
WCHAR buf[KL_NAMELENGTH];
|
|
|
|
|
|
|
|
if (GetKeyboardLayoutNameW(buf))
|
|
|
|
return WideCharToMultiByte( CP_ACP, 0, buf, -1, pszKLID, KL_NAMELENGTH, NULL, NULL ) != 0;
|
|
|
|
return FALSE;
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* GetKeyboardLayoutNameW (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
2003-11-14 04:32:43 +01:00
|
|
|
BOOL WINAPI GetKeyboardLayoutNameW(LPWSTR pwszKLID)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
if (USER_Driver.pGetKeyboardLayoutName)
|
|
|
|
return USER_Driver.pGetKeyboardLayoutName(pwszKLID);
|
|
|
|
return FALSE;
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* GetKeyNameTextA (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
INT WINAPI GetKeyNameTextA(LONG lParam, LPSTR lpBuffer, INT nSize)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
WCHAR buf[256];
|
|
|
|
INT ret;
|
|
|
|
|
|
|
|
if (!GetKeyNameTextW(lParam, buf, 256))
|
|
|
|
return 0;
|
|
|
|
ret = WideCharToMultiByte(CP_ACP, 0, buf, -1, lpBuffer, nSize, NULL, NULL);
|
|
|
|
if (!ret && nSize)
|
|
|
|
{
|
|
|
|
ret = nSize - 1;
|
|
|
|
lpBuffer[ret] = 0;
|
|
|
|
}
|
|
|
|
return ret;
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* GetKeyNameTextW (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
INT WINAPI GetKeyNameTextW(LONG lParam, LPWSTR lpBuffer, INT nSize)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
if (USER_Driver.pGetKeyNameText)
|
|
|
|
return USER_Driver.pGetKeyNameText( lParam, lpBuffer, nSize );
|
|
|
|
return 0;
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
2000-10-25 23:34:31 +02:00
|
|
|
/****************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* ToUnicode (USER32.@)
|
2000-10-25 23:34:31 +02:00
|
|
|
*/
|
|
|
|
INT WINAPI ToUnicode(UINT virtKey, UINT scanCode, LPBYTE lpKeyState,
|
|
|
|
LPWSTR lpwStr, int size, UINT flags)
|
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
return ToUnicodeEx(virtKey, scanCode, lpKeyState, lpwStr, size, flags, GetKeyboardLayout(0));
|
2000-10-25 23:34:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* ToUnicodeEx (USER32.@)
|
2000-10-25 23:34:31 +02:00
|
|
|
*/
|
|
|
|
INT WINAPI ToUnicodeEx(UINT virtKey, UINT scanCode, LPBYTE lpKeyState,
|
|
|
|
LPWSTR lpwStr, int size, UINT flags, HKL hkl)
|
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
if (USER_Driver.pToUnicodeEx)
|
|
|
|
return USER_Driver.pToUnicodeEx(virtKey, scanCode, lpKeyState, lpwStr, size, flags, hkl);
|
|
|
|
return 0;
|
2000-10-25 23:34:31 +02:00
|
|
|
}
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
/****************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* ToAscii (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
2003-11-14 04:32:43 +01:00
|
|
|
INT WINAPI ToAscii( UINT virtKey, UINT scanCode, LPBYTE lpKeyState,
|
|
|
|
LPWORD lpChar, UINT flags )
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
return ToAsciiEx(virtKey, scanCode, lpKeyState, lpChar, flags, GetKeyboardLayout(0));
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
1999-03-28 15:15:40 +02:00
|
|
|
/****************************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* ToAsciiEx (USER32.@)
|
1999-03-28 15:15:40 +02:00
|
|
|
*/
|
|
|
|
INT WINAPI ToAsciiEx( UINT virtKey, UINT scanCode, LPBYTE lpKeyState,
|
|
|
|
LPWORD lpChar, UINT flags, HKL dwhkl )
|
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
WCHAR uni_chars[2];
|
|
|
|
INT ret, n_ret;
|
|
|
|
|
|
|
|
ret = ToUnicodeEx(virtKey, scanCode, lpKeyState, uni_chars, 2, flags, dwhkl);
|
|
|
|
if (ret < 0) n_ret = 1; /* FIXME: make ToUnicode return 2 for dead chars */
|
|
|
|
else n_ret = ret;
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, uni_chars, n_ret, (LPSTR)lpChar, 2, NULL, NULL);
|
|
|
|
return ret;
|
1999-03-28 15:15:40 +02:00
|
|
|
}
|
|
|
|
|
1998-12-10 16:49:22 +01:00
|
|
|
/**********************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* ActivateKeyboardLayout (USER32.@)
|
1998-12-10 16:49:22 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HKL WINAPI ActivateKeyboardLayout(HKL hLayout, UINT flags)
|
1998-12-10 16:49:22 +01:00
|
|
|
{
|
2002-11-22 22:22:14 +01:00
|
|
|
TRACE_(keyboard)("(%p, %d)\n", hLayout, flags);
|
2003-11-14 04:32:43 +01:00
|
|
|
|
|
|
|
if (USER_Driver.pActivateKeyboardLayout)
|
|
|
|
return USER_Driver.pActivateKeyboardLayout(hLayout, flags);
|
1998-12-10 16:49:22 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
/***********************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* GetKeyboardLayoutList (USER32.@)
|
1999-02-28 12:13:16 +01:00
|
|
|
*
|
2002-06-01 01:06:46 +02:00
|
|
|
* Return number of values available if either input parm is
|
1999-02-28 12:13:16 +01:00
|
|
|
* 0, per MS documentation.
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
2003-11-14 04:32:43 +01:00
|
|
|
UINT WINAPI GetKeyboardLayoutList(INT nBuff, HKL *layouts)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2003-11-14 04:32:43 +01:00
|
|
|
TRACE_(keyboard)("(%d,%p)\n",nBuff,layouts);
|
|
|
|
|
|
|
|
if (USER_Driver.pGetKeyboardLayoutList)
|
|
|
|
return USER_Driver.pGetKeyboardLayoutList(nBuff, layouts);
|
|
|
|
return 0;
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* RegisterHotKey (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
2005-04-25 13:33:34 +02:00
|
|
|
BOOL WINAPI RegisterHotKey(HWND hwnd,INT id,UINT modifiers,UINT vk)
|
|
|
|
{
|
|
|
|
FIXME_(keyboard)("(%p,%d,0x%08x,%d): stub\n",hwnd,id,modifiers,vk);
|
|
|
|
return TRUE;
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2000-12-22 02:38:01 +01:00
|
|
|
* UnregisterHotKey (USER32.@)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
2005-04-25 13:33:34 +02:00
|
|
|
BOOL WINAPI UnregisterHotKey(HWND hwnd,INT id)
|
|
|
|
{
|
|
|
|
FIXME_(keyboard)("(%p,%d): stub\n",hwnd,id);
|
|
|
|
return TRUE;
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
1998-12-10 16:49:22 +01:00
|
|
|
/***********************************************************************
|
2002-11-18 20:47:20 +01:00
|
|
|
* LoadKeyboardLayoutW (USER32.@)
|
1998-12-10 16:49:22 +01:00
|
|
|
*/
|
2002-11-18 20:47:20 +01:00
|
|
|
HKL WINAPI LoadKeyboardLayoutW(LPCWSTR pwszKLID, UINT Flags)
|
1998-12-10 16:49:22 +01:00
|
|
|
{
|
2002-11-18 20:47:20 +01:00
|
|
|
TRACE_(keyboard)("(%s, %d)\n", debugstr_w(pwszKLID), Flags);
|
2003-11-14 04:32:43 +01:00
|
|
|
|
|
|
|
if (USER_Driver.pLoadKeyboardLayout)
|
|
|
|
return USER_Driver.pLoadKeyboardLayout(pwszKLID, Flags);
|
|
|
|
return 0;
|
1998-12-10 16:49:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2002-11-18 20:47:20 +01:00
|
|
|
* LoadKeyboardLayoutA (USER32.@)
|
1998-12-10 16:49:22 +01:00
|
|
|
*/
|
2002-11-18 20:47:20 +01:00
|
|
|
HKL WINAPI LoadKeyboardLayoutA(LPCSTR pwszKLID, UINT Flags)
|
1998-12-10 16:49:22 +01:00
|
|
|
{
|
2002-11-18 20:47:20 +01:00
|
|
|
HKL ret;
|
|
|
|
UNICODE_STRING pwszKLIDW;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-11-18 20:47:20 +01:00
|
|
|
if (pwszKLID) RtlCreateUnicodeStringFromAsciiz(&pwszKLIDW, pwszKLID);
|
|
|
|
else pwszKLIDW.Buffer = NULL;
|
|
|
|
|
|
|
|
ret = LoadKeyboardLayoutW(pwszKLIDW.Buffer, Flags);
|
|
|
|
RtlFreeUnicodeString(&pwszKLIDW);
|
|
|
|
return ret;
|
1998-12-10 16:49:22 +01:00
|
|
|
}
|
2002-01-15 21:41:41 +01:00
|
|
|
|
|
|
|
|
2003-11-14 04:32:43 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* UnloadKeyboardLayout (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI UnloadKeyboardLayout(HKL hkl)
|
|
|
|
{
|
|
|
|
TRACE_(keyboard)("(%p)\n", hkl);
|
|
|
|
|
|
|
|
if (USER_Driver.pUnloadKeyboardLayout)
|
|
|
|
return USER_Driver.pUnloadKeyboardLayout(hkl);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-01-15 21:41:41 +01:00
|
|
|
typedef struct __TRACKINGLIST {
|
|
|
|
TRACKMOUSEEVENT tme;
|
|
|
|
POINT pos; /* center of hover rectangle */
|
|
|
|
INT iHoverTime; /* elapsed time the cursor has been inside of the hover rect */
|
2002-06-01 01:06:46 +02:00
|
|
|
} _TRACKINGLIST;
|
2002-01-15 21:41:41 +01:00
|
|
|
|
|
|
|
static _TRACKINGLIST TrackingList[10];
|
|
|
|
static int iTrackMax = 0;
|
|
|
|
static UINT_PTR timer;
|
|
|
|
static const INT iTimerInterval = 50; /* msec for timer interval */
|
|
|
|
|
|
|
|
static void CALLBACK TrackMouseEventProc(HWND hwndUnused, UINT uMsg, UINT_PTR idEvent,
|
|
|
|
DWORD dwTime)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
POINT pos;
|
2002-12-10 20:05:12 +01:00
|
|
|
POINT posClient;
|
2002-01-15 21:41:41 +01:00
|
|
|
HWND hwnd;
|
2003-11-26 06:06:59 +01:00
|
|
|
INT nonclient;
|
2002-01-15 21:41:41 +01:00
|
|
|
INT hoverwidth = 0, hoverheight = 0;
|
2003-11-26 06:06:59 +01:00
|
|
|
RECT client;
|
2002-01-15 21:41:41 +01:00
|
|
|
|
|
|
|
GetCursorPos(&pos);
|
|
|
|
hwnd = WindowFromPoint(pos);
|
|
|
|
|
|
|
|
SystemParametersInfoA(SPI_GETMOUSEHOVERWIDTH, 0, &hoverwidth, 0);
|
|
|
|
SystemParametersInfoA(SPI_GETMOUSEHOVERHEIGHT, 0, &hoverheight, 0);
|
|
|
|
|
|
|
|
/* loop through tracking events we are processing */
|
|
|
|
while (i < iTrackMax) {
|
2003-11-26 06:06:59 +01:00
|
|
|
if (TrackingList[i].tme.dwFlags & TME_NONCLIENT) {
|
|
|
|
nonclient = 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nonclient = 0;
|
|
|
|
}
|
|
|
|
|
2002-01-15 21:41:41 +01:00
|
|
|
/* see if this tracking event is looking for TME_LEAVE and that the */
|
|
|
|
/* mouse has left the window */
|
2003-11-26 06:06:59 +01:00
|
|
|
if (TrackingList[i].tme.dwFlags & TME_LEAVE) {
|
|
|
|
if (TrackingList[i].tme.hwndTrack != hwnd) {
|
|
|
|
if (nonclient) {
|
|
|
|
PostMessageA(TrackingList[i].tme.hwndTrack, WM_NCMOUSELEAVE, 0, 0);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
PostMessageA(TrackingList[i].tme.hwndTrack, WM_MOUSELEAVE, 0, 0);
|
|
|
|
}
|
2002-01-15 21:41:41 +01:00
|
|
|
|
2003-11-26 06:06:59 +01:00
|
|
|
/* remove the TME_LEAVE flag */
|
|
|
|
TrackingList[i].tme.dwFlags ^= TME_LEAVE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
GetClientRect(hwnd, &client);
|
|
|
|
MapWindowPoints(hwnd, NULL, (LPPOINT)&client, 2);
|
|
|
|
if(PtInRect(&client, pos)) {
|
|
|
|
if (nonclient) {
|
|
|
|
PostMessageA(TrackingList[i].tme.hwndTrack, WM_NCMOUSELEAVE, 0, 0);
|
|
|
|
/* remove the TME_LEAVE flag */
|
|
|
|
TrackingList[i].tme.dwFlags ^= TME_LEAVE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (!nonclient) {
|
|
|
|
PostMessageA(TrackingList[i].tme.hwndTrack, WM_MOUSELEAVE, 0, 0);
|
|
|
|
/* remove the TME_LEAVE flag */
|
|
|
|
TrackingList[i].tme.dwFlags ^= TME_LEAVE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-01-15 21:41:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* see if we are tracking hovering for this hwnd */
|
|
|
|
if(TrackingList[i].tme.dwFlags & TME_HOVER) {
|
|
|
|
/* add the timer interval to the hovering time */
|
2002-06-01 01:06:46 +02:00
|
|
|
TrackingList[i].iHoverTime+=iTimerInterval;
|
|
|
|
|
2002-01-15 21:41:41 +01:00
|
|
|
/* has the cursor moved outside the rectangle centered around pos? */
|
|
|
|
if((abs(pos.x - TrackingList[i].pos.x) > (hoverwidth / 2.0))
|
|
|
|
|| (abs(pos.y - TrackingList[i].pos.y) > (hoverheight / 2.0)))
|
|
|
|
{
|
|
|
|
/* record this new position as the current position and reset */
|
|
|
|
/* the iHoverTime variable to 0 */
|
|
|
|
TrackingList[i].pos = pos;
|
|
|
|
TrackingList[i].iHoverTime = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* has the mouse hovered long enough? */
|
|
|
|
if(TrackingList[i].iHoverTime <= TrackingList[i].tme.dwHoverTime)
|
2003-11-26 06:06:59 +01:00
|
|
|
{
|
2005-04-25 13:33:34 +02:00
|
|
|
posClient.x = pos.x;
|
|
|
|
posClient.y = pos.y;
|
|
|
|
ScreenToClient(hwnd, &posClient);
|
2003-11-26 06:06:59 +01:00
|
|
|
if (nonclient) {
|
|
|
|
PostMessageW(TrackingList[i].tme.hwndTrack, WM_NCMOUSEHOVER,
|
|
|
|
get_key_state(), MAKELPARAM( posClient.x, posClient.y ));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
PostMessageW(TrackingList[i].tme.hwndTrack, WM_MOUSEHOVER,
|
|
|
|
get_key_state(), MAKELPARAM( posClient.x, posClient.y ));
|
|
|
|
}
|
2002-01-15 21:41:41 +01:00
|
|
|
|
|
|
|
/* stop tracking mouse hover */
|
|
|
|
TrackingList[i].tme.dwFlags ^= TME_HOVER;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* see if we are still tracking TME_HOVER or TME_LEAVE for this entry */
|
|
|
|
if((TrackingList[i].tme.dwFlags & TME_HOVER) ||
|
|
|
|
(TrackingList[i].tme.dwFlags & TME_LEAVE)) {
|
|
|
|
i++;
|
|
|
|
} else { /* remove this entry from the tracking list */
|
|
|
|
TrackingList[i] = TrackingList[--iTrackMax];
|
|
|
|
}
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-01-15 21:41:41 +01:00
|
|
|
/* stop the timer if the tracking list is empty */
|
|
|
|
if(iTrackMax == 0) {
|
|
|
|
KillTimer(0, timer);
|
|
|
|
timer = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* TrackMouseEvent [USER32]
|
|
|
|
*
|
|
|
|
* Requests notification of mouse events
|
|
|
|
*
|
|
|
|
* During mouse tracking WM_MOUSEHOVER or WM_MOUSELEAVE events are posted
|
|
|
|
* to the hwnd specified in the ptme structure. After the event message
|
|
|
|
* is posted to the hwnd, the entry in the queue is removed.
|
|
|
|
*
|
|
|
|
* If the current hwnd isn't ptme->hwndTrack the TME_HOVER flag is completely
|
|
|
|
* ignored. The TME_LEAVE flag results in a WM_MOUSELEAVE message being posted
|
|
|
|
* immediately and the TME_LEAVE flag being ignored.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* ptme [I,O] pointer to TRACKMOUSEEVENT information structure.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: non-zero
|
|
|
|
* Failure: zero
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
BOOL WINAPI
|
|
|
|
TrackMouseEvent (TRACKMOUSEEVENT *ptme)
|
|
|
|
{
|
|
|
|
DWORD flags = 0;
|
|
|
|
int i = 0;
|
2003-11-26 06:06:59 +01:00
|
|
|
BOOL cancel = 0, hover = 0, leave = 0, query = 0, nonclient = 0, inclient = 0;
|
2002-01-15 21:41:41 +01:00
|
|
|
HWND hwnd;
|
|
|
|
POINT pos;
|
2003-11-26 06:06:59 +01:00
|
|
|
RECT client;
|
|
|
|
|
2002-01-15 21:41:41 +01:00
|
|
|
|
|
|
|
pos.x = 0;
|
|
|
|
pos.y = 0;
|
2003-11-26 06:06:59 +01:00
|
|
|
SetRectEmpty(&client);
|
2002-01-15 21:41:41 +01:00
|
|
|
|
2002-11-22 22:22:14 +01:00
|
|
|
TRACE("%lx, %lx, %p, %lx\n", ptme->cbSize, ptme->dwFlags, ptme->hwndTrack, ptme->dwHoverTime);
|
2002-01-15 21:41:41 +01:00
|
|
|
|
|
|
|
if (ptme->cbSize != sizeof(TRACKMOUSEEVENT)) {
|
|
|
|
WARN("wrong TRACKMOUSEEVENT size from app\n");
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER); /* FIXME not sure if this is correct */
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
flags = ptme->dwFlags;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-01-15 21:41:41 +01:00
|
|
|
/* if HOVER_DEFAULT was specified replace this with the systems current value */
|
|
|
|
if(ptme->dwHoverTime == HOVER_DEFAULT)
|
|
|
|
SystemParametersInfoA(SPI_GETMOUSEHOVERTIME, 0, &(ptme->dwHoverTime), 0);
|
|
|
|
|
|
|
|
GetCursorPos(&pos);
|
2002-06-01 01:06:46 +02:00
|
|
|
hwnd = WindowFromPoint(pos);
|
2002-01-15 21:41:41 +01:00
|
|
|
|
|
|
|
if ( flags & TME_CANCEL ) {
|
|
|
|
flags &= ~ TME_CANCEL;
|
|
|
|
cancel = 1;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-01-15 21:41:41 +01:00
|
|
|
if ( flags & TME_HOVER ) {
|
|
|
|
flags &= ~ TME_HOVER;
|
|
|
|
hover = 1;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-01-15 21:41:41 +01:00
|
|
|
if ( flags & TME_LEAVE ) {
|
|
|
|
flags &= ~ TME_LEAVE;
|
|
|
|
leave = 1;
|
|
|
|
}
|
|
|
|
|
2003-11-26 06:06:59 +01:00
|
|
|
if ( flags & TME_NONCLIENT ) {
|
|
|
|
flags &= ~ TME_NONCLIENT;
|
|
|
|
nonclient = 1;
|
|
|
|
}
|
|
|
|
|
2002-01-15 21:41:41 +01:00
|
|
|
/* fill the TRACKMOUSEEVENT struct with the current tracking for the given hwnd */
|
|
|
|
if ( flags & TME_QUERY ) {
|
|
|
|
flags &= ~ TME_QUERY;
|
|
|
|
query = 1;
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
/* Find the tracking list entry with the matching hwnd */
|
|
|
|
while((i < iTrackMax) && (TrackingList[i].tme.hwndTrack != ptme->hwndTrack)) {
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* hwnd found, fill in the ptme struct */
|
|
|
|
if(i < iTrackMax)
|
|
|
|
*ptme = TrackingList[i].tme;
|
|
|
|
else
|
|
|
|
ptme->dwFlags = 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-01-15 21:41:41 +01:00
|
|
|
return TRUE; /* return here, TME_QUERY is retrieving information */
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( flags )
|
|
|
|
FIXME("Unknown flag(s) %08lx\n", flags );
|
|
|
|
|
|
|
|
if(cancel) {
|
|
|
|
/* find a matching hwnd if one exists */
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
while((i < iTrackMax) && (TrackingList[i].tme.hwndTrack != ptme->hwndTrack)) {
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(i < iTrackMax) {
|
|
|
|
TrackingList[i].tme.dwFlags &= ~(ptme->dwFlags & ~TME_CANCEL);
|
|
|
|
|
|
|
|
/* if we aren't tracking on hover or leave remove this entry */
|
|
|
|
if(!((TrackingList[i].tme.dwFlags & TME_HOVER) ||
|
|
|
|
(TrackingList[i].tme.dwFlags & TME_LEAVE)))
|
|
|
|
{
|
|
|
|
TrackingList[i] = TrackingList[--iTrackMax];
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-01-15 21:41:41 +01:00
|
|
|
if(iTrackMax == 0) {
|
|
|
|
KillTimer(0, timer);
|
|
|
|
timer = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* see if hwndTrack isn't the current window */
|
|
|
|
if(ptme->hwndTrack != hwnd) {
|
|
|
|
if(leave) {
|
2003-11-26 06:06:59 +01:00
|
|
|
if(nonclient) {
|
|
|
|
PostMessageA(ptme->hwndTrack, WM_NCMOUSELEAVE, 0, 0);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
PostMessageA(ptme->hwndTrack, WM_MOUSELEAVE, 0, 0);
|
|
|
|
}
|
2002-01-15 21:41:41 +01:00
|
|
|
}
|
|
|
|
} else {
|
2003-11-26 06:06:59 +01:00
|
|
|
GetClientRect(ptme->hwndTrack, &client);
|
|
|
|
MapWindowPoints(ptme->hwndTrack, NULL, (LPPOINT)&client, 2);
|
|
|
|
if(PtInRect(&client, pos)) {
|
|
|
|
inclient = 1;
|
|
|
|
}
|
|
|
|
if(nonclient && inclient) {
|
|
|
|
PostMessageA(ptme->hwndTrack, WM_NCMOUSELEAVE, 0, 0);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if(!nonclient && !inclient) {
|
|
|
|
PostMessageA(ptme->hwndTrack, WM_MOUSELEAVE, 0, 0);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-01-15 21:41:41 +01:00
|
|
|
/* See if this hwnd is already being tracked and update the tracking flags */
|
|
|
|
for(i = 0; i < iTrackMax; i++) {
|
|
|
|
if(TrackingList[i].tme.hwndTrack == ptme->hwndTrack) {
|
2003-11-26 06:06:59 +01:00
|
|
|
TrackingList[i].tme.dwFlags = 0;
|
|
|
|
|
2002-01-15 21:41:41 +01:00
|
|
|
if(hover) {
|
|
|
|
TrackingList[i].tme.dwFlags |= TME_HOVER;
|
|
|
|
TrackingList[i].tme.dwHoverTime = ptme->dwHoverTime;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-01-15 21:41:41 +01:00
|
|
|
if(leave)
|
|
|
|
TrackingList[i].tme.dwFlags |= TME_LEAVE;
|
|
|
|
|
2003-11-26 06:06:59 +01:00
|
|
|
if(nonclient)
|
|
|
|
TrackingList[i].tme.dwFlags |= TME_NONCLIENT;
|
|
|
|
|
2002-01-15 21:41:41 +01:00
|
|
|
/* reset iHoverTime as per winapi specs */
|
2002-06-01 01:06:46 +02:00
|
|
|
TrackingList[i].iHoverTime = 0;
|
|
|
|
|
2002-01-15 21:41:41 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2002-01-15 21:41:41 +01:00
|
|
|
|
|
|
|
/* if the tracking list is full return FALSE */
|
|
|
|
if (iTrackMax == sizeof (TrackingList) / sizeof(*TrackingList)) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Adding new mouse event to the tracking list */
|
|
|
|
TrackingList[iTrackMax].tme = *ptme;
|
|
|
|
|
|
|
|
/* Initialize HoverInfo variables even if not hover tracking */
|
|
|
|
TrackingList[iTrackMax].iHoverTime = 0;
|
|
|
|
TrackingList[iTrackMax].pos = pos;
|
|
|
|
|
|
|
|
iTrackMax++;
|
|
|
|
|
|
|
|
if (!timer) {
|
|
|
|
timer = SetTimer(0, 0, iTimerInterval, TrackMouseEventProc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|