Avoid a couple of dependencies on input.c internal variables.

This commit is contained in:
Alexandre Julliard 2000-12-16 20:37:16 +00:00
parent b583ed33de
commit ce1398e384
6 changed files with 52 additions and 62 deletions

View File

@ -504,18 +504,18 @@ static HRESULT WINAPI SysMouseAImpl_Acquire(LPDIRECTINPUTDEVICE2A iface)
/* Init the mouse state */ /* Init the mouse state */
if (This->absolute) { if (This->absolute) {
This->m_state.lX = PosX; GetCursorPos( &point );
This->m_state.lY = PosY; This->m_state.lX = point.x;
This->m_state.lY = point.y;
This->prevX = PosX; This->prevX = point.x;
This->prevY = PosY; This->prevY = point.y;
} else { } else {
This->m_state.lX = 0; This->m_state.lX = 0;
This->m_state.lY = 0; This->m_state.lY = 0;
} }
This->m_state.rgbButtons[0] = (MouseButtonsStates[0] ? 0xFF : 0x00); This->m_state.rgbButtons[0] = (GetKeyState(VK_LBUTTON) ? 0xFF : 0x00);
This->m_state.rgbButtons[1] = (MouseButtonsStates[1] ? 0xFF : 0x00); This->m_state.rgbButtons[1] = (GetKeyState(VK_MBUTTON) ? 0xFF : 0x00);
This->m_state.rgbButtons[2] = (MouseButtonsStates[2] ? 0xFF : 0x00); This->m_state.rgbButtons[2] = (GetKeyState(VK_RBUTTON) ? 0xFF : 0x00);
/* Install our own mouse event handler */ /* Install our own mouse event handler */
MOUSE_Enable(dinput_mouse_event); MOUSE_Enable(dinput_mouse_event);
@ -531,7 +531,7 @@ static HRESULT WINAPI SysMouseAImpl_Acquire(LPDIRECTINPUTDEVICE2A iface)
point.x = This->win_centerX; point.x = This->win_centerX;
point.y = This->win_centerY; point.y = This->win_centerY;
MapWindowPoints(This->win, HWND_DESKTOP, &point, 1); MapWindowPoints(This->win, HWND_DESKTOP, &point, 1);
USER_Driver.pMoveCursor( point.x, point.y ); SetCursorPos( point.x, point.y );
#ifdef MOUSE_HACK #ifdef MOUSE_HACK
This->need_warp = WARP_DONE; This->need_warp = WARP_DONE;
#else #else
@ -602,7 +602,7 @@ static HRESULT WINAPI SysMouseAImpl_GetDeviceState(
point.x = This->win_centerX; point.x = This->win_centerX;
point.y = This->win_centerY; point.y = This->win_centerY;
MapWindowPoints(This->win, HWND_DESKTOP, &point, 1); MapWindowPoints(This->win, HWND_DESKTOP, &point, 1);
USER_Driver.pMoveCursor( point.x, point.y ); SetCursorPos( point.x, point.y );
#ifdef MOUSE_HACK #ifdef MOUSE_HACK
This->need_warp = WARP_DONE; This->need_warp = WARP_DONE;
@ -672,8 +672,7 @@ static HRESULT WINAPI SysMouseAImpl_GetDeviceData(LPDIRECTINPUTDEVICE2A iface,
point.x = This->win_centerX; point.x = This->win_centerX;
point.y = This->win_centerY; point.y = This->win_centerY;
MapWindowPoints(This->win, HWND_DESKTOP, &point, 1); MapWindowPoints(This->win, HWND_DESKTOP, &point, 1);
SetCursorPos( point.x, point.y );
USER_Driver.pMoveCursor( point.x, point.y );
#ifdef MOUSE_HACK #ifdef MOUSE_HACK
This->need_warp = WARP_DONE; This->need_warp = WARP_DONE;

View File

@ -14,17 +14,6 @@ extern BOOL AsyncMouseButtonsStates[3];
extern BYTE InputKeyStateTable[256]; extern BYTE InputKeyStateTable[256];
extern BYTE QueueKeyStateTable[256]; extern BYTE QueueKeyStateTable[256];
extern BYTE AsyncKeyStateTable[256]; extern BYTE AsyncKeyStateTable[256];
extern DWORD PosX, PosY;
extern BOOL SwappedButtons;
#define GET_KEYSTATE() \
((MouseButtonsStates[SwappedButtons ? 2 : 0] ? MK_LBUTTON : 0) | \
(MouseButtonsStates[1] ? MK_RBUTTON : 0) | \
(MouseButtonsStates[SwappedButtons ? 0 : 2] ? MK_MBUTTON : 0) | \
(InputKeyStateTable[VK_SHIFT] & 0x80 ? MK_SHIFT : 0) | \
(InputKeyStateTable[VK_CONTROL] & 0x80 ? MK_CONTROL : 0))
#endif /* __WINE_INPUT_H */ #endif /* __WINE_INPUT_H */

View File

@ -1518,35 +1518,6 @@ BOOL WINAPI ClipCursor( const RECT *rect )
} }
/***********************************************************************
* GetCursorPos16 (USER.17)
*/
BOOL16 WINAPI GetCursorPos16( POINT16 *pt )
{
if (!pt) return 0;
pt->x = PosX;
pt->y = PosY;
TRACE_(cursor)("ret=%d,%d\n", pt->x, pt->y );
return 1;
}
/***********************************************************************
* GetCursorPos (USER32.229)
*/
BOOL WINAPI GetCursorPos( POINT *pt )
{
BOOL ret;
POINT16 pt16;
ret = GetCursorPos16( &pt16 );
if (pt) CONV_POINT16TO32( &pt16, pt );
return ((pt) ? ret : 0);
}
/*********************************************************************** /***********************************************************************
* GetClipCursor16 (USER.309) * GetClipCursor16 (USER.309)
*/ */

View File

@ -39,7 +39,7 @@ DECLARE_DEBUG_CHANNEL(keyboard);
DECLARE_DEBUG_CHANNEL(win); DECLARE_DEBUG_CHANNEL(win);
static BOOL InputEnabled = TRUE; static BOOL InputEnabled = TRUE;
BOOL SwappedButtons = FALSE; static BOOL SwappedButtons;
BOOL MouseButtonsStates[3]; BOOL MouseButtonsStates[3];
BOOL AsyncMouseButtonsStates[3]; BOOL AsyncMouseButtonsStates[3];
@ -48,7 +48,14 @@ BYTE QueueKeyStateTable[256];
BYTE AsyncKeyStateTable[256]; BYTE AsyncKeyStateTable[256];
/* Storage for the USER-maintained mouse positions */ /* Storage for the USER-maintained mouse positions */
DWORD PosX, PosY; static DWORD PosX, PosY;
#define GET_KEYSTATE() \
((MouseButtonsStates[SwappedButtons ? 2 : 0] ? MK_LBUTTON : 0) | \
(MouseButtonsStates[1] ? MK_RBUTTON : 0) | \
(MouseButtonsStates[SwappedButtons ? 0 : 2] ? MK_MBUTTON : 0) | \
(InputKeyStateTable[VK_SHIFT] & 0x80 ? MK_SHIFT : 0) | \
(InputKeyStateTable[VK_CONTROL] & 0x80 ? MK_CONTROL : 0))
typedef union typedef union
{ {
@ -201,7 +208,7 @@ void WINAPI mouse_event( DWORD dwFlags, DWORD dx, DWORD dy,
* Otherwise, we need to determine that info ourselves (probably * Otherwise, we need to determine that info ourselves (probably
* less accurate, but we can't help that ...). * less accurate, but we can't help that ...).
*/ */
if ( !IsBadReadPtr( (LPVOID)dwExtraInfo, sizeof(WINE_MOUSEEVENT) ) if (dwExtraInfo && !IsBadReadPtr( (LPVOID)dwExtraInfo, sizeof(WINE_MOUSEEVENT) )
&& ((WINE_MOUSEEVENT *)dwExtraInfo)->magic == WINE_MOUSEEVENT_MAGIC ) && ((WINE_MOUSEEVENT *)dwExtraInfo)->magic == WINE_MOUSEEVENT_MAGIC )
{ {
WINE_MOUSEEVENT *wme = (WINE_MOUSEEVENT *)dwExtraInfo; WINE_MOUSEEVENT *wme = (WINE_MOUSEEVENT *)dwExtraInfo;
@ -332,6 +339,31 @@ BOOL WINAPI SwapMouseButton( BOOL fSwap )
return ret; return ret;
} }
/***********************************************************************
* GetCursorPos16 (USER.17)
*/
BOOL16 WINAPI GetCursorPos16( POINT16 *pt )
{
if (!pt) return 0;
pt->x = PosX;
pt->y = PosY;
return 1;
}
/***********************************************************************
* GetCursorPos (USER32.229)
*/
BOOL WINAPI GetCursorPos( POINT *pt )
{
if (!pt) return 0;
pt->x = PosX;
pt->y = PosY;
return 1;
}
/********************************************************************** /**********************************************************************
* EVENT_Capture * EVENT_Capture
* *

View File

@ -2938,13 +2938,10 @@ Pos: /* -----------------------------------------------------------------------
EVENT_Synchronize(); /* Synchronize with the host window system */ EVENT_Synchronize(); /* Synchronize with the host window system */
if (!GetCapture() && ((wndPtr->dwStyle & WS_VISIBLE) || (flags & SWP_HIDEWINDOW))) if (!GetCapture() && ((wndPtr->dwStyle & WS_VISIBLE) || (flags & SWP_HIDEWINDOW)))
{ {
/* Simulate a mouse event to set the cursor */ /* Simulate a mouse event to set the cursor */
int iWndsLocks = WIN_SuspendWndsLock(); int iWndsLocks = WIN_SuspendWndsLock();
mouse_event( MOUSEEVENTF_MOVE, 0, 0, 0, 0 );
hardware_event( WM_MOUSEMOVE, GET_KEYSTATE(), 0,
PosX, PosY, GetTickCount(), 0 );
WIN_RestoreWndsLock(iWndsLocks); WIN_RestoreWndsLock(iWndsLocks);
} }

View File

@ -277,11 +277,13 @@ static void EVENT_ProcessEvent( XEvent *event )
if ((event->type == DGAKeyPressEventType) || if ((event->type == DGAKeyPressEventType) ||
(event->type == DGAKeyReleaseEventType)) { (event->type == DGAKeyReleaseEventType)) {
/* Fill a XKeyEvent to send to EVENT_Key */ /* Fill a XKeyEvent to send to EVENT_Key */
POINT pt;
XKeyEvent ke; XKeyEvent ke;
XDGAKeyEvent *evt = (XDGAKeyEvent *) event; XDGAKeyEvent *evt = (XDGAKeyEvent *) event;
TRACE("DGAKeyPress/ReleaseEvent received.\n"); TRACE("DGAKeyPress/ReleaseEvent received.\n");
GetCursorPos( &pt );
if (evt->type == DGAKeyReleaseEventType) if (evt->type == DGAKeyReleaseEventType)
ke.type = KeyRelease; ke.type = KeyRelease;
else else
@ -293,8 +295,8 @@ static void EVENT_ProcessEvent( XEvent *event )
ke.root = 0; ke.root = 0;
ke.subwindow = 0; ke.subwindow = 0;
ke.time = evt->time; ke.time = evt->time;
ke.x = PosX; ke.x = pt.x;
ke.y = PosY; ke.y = pt.y;
ke.x_root = -1; ke.x_root = -1;
ke.y_root = -1; ke.y_root = -1;
ke.state = evt->state; ke.state = evt->state;