Added the possibility to have mouse movements reported relative to

Wine's mouse driver.
This commit is contained in:
Lionel Ulmer 1999-11-07 21:25:57 +00:00 committed by Alexandre Julliard
parent edf3e434b0
commit acc7467c03
17 changed files with 197 additions and 164 deletions

View File

@ -14,6 +14,17 @@ extern BOOL AsyncMouseButtonsStates[3];
extern BYTE InputKeyStateTable[256];
extern BYTE QueueKeyStateTable[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 */

View File

@ -29,7 +29,6 @@ typedef struct tagEVENT_DRIVER {
BOOL (*pInit)(void);
void (*pSynchronize)(void);
BOOL (*pCheckFocus)(void);
BOOL (*pQueryPointer)(DWORD *, DWORD *, DWORD *);
void (*pUserRepaintDisable)(BOOL);
} EVENT_DRIVER;
@ -38,12 +37,10 @@ extern EVENT_DRIVER *EVENT_Driver;
extern BOOL EVENT_Init( void );
extern void EVENT_Synchronize( void );
extern BOOL EVENT_CheckFocus( void );
extern BOOL EVENT_QueryPointer(DWORD *posX, DWORD *posY, DWORD *state);
/* input.c */
extern HWND EVENT_Capture( HWND, INT16 );
extern BOOL EVENT_QueryPointer( DWORD *posX, DWORD *posY, DWORD *state );
extern void joySendMessages(void);

View File

@ -35,6 +35,7 @@ VOID WINAPI MOUSE_Disable(VOID);
/* Wine internals */
typedef struct tagMOUSE_DRIVER {
VOID (*pInit)(VOID);
VOID (*pSetCursor)(struct tagCURSORICONINFO *);
VOID (*pMoveCursor)(WORD, WORD);
BOOL (*pEnableWarpPointer)(BOOL);
@ -52,8 +53,8 @@ typedef struct _WINE_MOUSEEVENT
} WINE_MOUSEEVENT;
void MOUSE_SendEvent( DWORD mouseStatus, DWORD posX, DWORD posY,
DWORD keyState, DWORD time, HWND hWnd );
extern void MOUSE_SendEvent( DWORD mouseStatus, DWORD posX, DWORD posY,
DWORD keyState, DWORD time, HWND hWnd );
/***********************************
* MouseWheel support (defines)

View File

@ -99,7 +99,6 @@ extern struct tagEVENT_DRIVER TTYDRV_EVENT_Driver;
extern BOOL TTYDRV_EVENT_Init(void);
extern void TTYDRV_EVENT_Synchronize(void);
extern BOOL TTYDRV_EVENT_CheckFocus(void);
extern BOOL TTYDRV_EVENT_QueryPointer(DWORD *posX, DWORD *posY, DWORD *state);
extern void TTYDRV_EVENT_UserRepaintDisable(BOOL bDisable);
/* TTY keyboard driver */
@ -144,6 +143,7 @@ extern void TTYDRV_MONITOR_SetScreenSaveTimeout(struct tagMONITOR *pMonitor, int
extern struct tagMOUSE_DRIVER TTYDRV_MOUSE_Driver;
extern void TTYDRV_MOUSE_Init();
extern void TTYDRV_MOUSE_SetCursor(struct tagCURSORICONINFO *lpCursor);
extern void TTYDRV_MOUSE_MoveCursor(WORD wAbsX, WORD wAbsY);
extern BOOL TTYDRV_MOUSE_EnableWarpPointer(BOOL bEnable);

View File

@ -369,12 +369,19 @@ extern int X11DRV_DESKTOP_GetScreenDepth(struct tagDESKTOP *pDesktop);
extern struct tagEVENT_DRIVER X11DRV_EVENT_Driver;
extern WORD X11DRV_EVENT_XStateToKeyState( int state ) ;
extern BOOL X11DRV_EVENT_Init(void);
extern void X11DRV_EVENT_Synchronize( void );
extern BOOL X11DRV_EVENT_CheckFocus( void );
extern BOOL X11DRV_EVENT_QueryPointer(DWORD *posX, DWORD *posY, DWORD *state);
extern void X11DRV_EVENT_UserRepaintDisable( BOOL bDisable );
typedef enum {
X11DRV_INPUT_RELATIVE,
X11DRV_INPUT_ABSOLUTE
} INPUT_TYPE;
extern INPUT_TYPE X11DRV_EVENT_SetInputMehod(INPUT_TYPE type);
/* X11 keyboard driver */
extern struct tagKEYBOARD_DRIVER X11DRV_KEYBOARD_Driver;
@ -425,7 +432,7 @@ extern void X11DRV_MONITOR_SetScreenSaveTimeout(struct tagMONITOR *pMonitor, int
extern struct tagMOUSE_DRIVER X11DRV_MOUSE_Driver;
extern BOOL X11DRV_MOUSE_DisableWarpPointer;
extern void X11DRV_MOUSE_Init();
extern void X11DRV_MOUSE_SetCursor(struct tagCURSORICONINFO *lpCursor);
extern void X11DRV_MOUSE_MoveCursor(WORD wAbsX, WORD wAbsY);
extern BOOL X11DRV_MOUSE_EnableWarpPointer(BOOL bEnable);

View File

@ -1499,28 +1499,11 @@ BOOL WINAPI ClipCursor( const RECT *rect )
*/
BOOL16 WINAPI GetCursorPos16( POINT16 *pt )
{
DWORD posX, posY, state;
if (!pt) return 0;
if (!EVENT_QueryPointer( &posX, &posY, &state ))
pt->x = pt->y = 0;
else
{
pt->x = posX;
pt->y = posY;
if (state & MK_LBUTTON)
AsyncMouseButtonsStates[0] = MouseButtonsStates[0] = TRUE;
else
MouseButtonsStates[0] = FALSE;
if (state & MK_MBUTTON)
AsyncMouseButtonsStates[1] = MouseButtonsStates[1] = TRUE;
else
MouseButtonsStates[1] = FALSE;
if (state & MK_RBUTTON)
AsyncMouseButtonsStates[2] = MouseButtonsStates[2] = TRUE;
else
MouseButtonsStates[2] = FALSE;
}
pt->x = PosX;
pt->y = PosY;
TRACE_(cursor)("ret=%d,%d\n", pt->x, pt->y );
return 1;
}

View File

@ -41,6 +41,7 @@
#include "debugtools.h"
#include "dinput.h"
#include "display.h"
#include "input.h"
#include "keyboard.h"
#include "message.h"
#include "mouse.h"
@ -320,7 +321,7 @@ static HRESULT WINAPI IDirectInputAImpl_CreateDevice(
JoystickAImpl* newDevice;
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(JoystickAImpl));
newDevice->ref = 1;
ICOM_VTBL(newDevice) = &JoystickAvt;
ICOM_VTBL(newDevice) = &JoystickAvt;
newDevice->joyfd = -1;
memcpy(&(newDevice->guid),rguid,sizeof(*rguid));
*pdev=(IDirectInputDeviceA*)newDevice;
@ -1012,7 +1013,6 @@ static HRESULT WINAPI SysMouseAImpl_GetDeviceState(
LPDIRECTINPUTDEVICE2A iface,DWORD len,LPVOID ptr
) {
ICOM_THIS(SysMouseAImpl,iface);
DWORD rx, ry, state;
struct DIMOUSESTATE *mstate = (struct DIMOUSESTATE *) ptr;
TRACE("(this=%p,0x%08lx,%p): \n",This,len,ptr);
@ -1023,25 +1023,24 @@ static HRESULT WINAPI SysMouseAImpl_GetDeviceState(
return DIERR_INVALIDPARAM;
}
/* Get the mouse position */
EVENT_QueryPointer(&rx, &ry, &state);
TRACE("(X:%ld - Y:%ld)\n", rx, ry);
TRACE("(X:%ld - Y:%ld)\n", PosX, PosY);
/* Fill the mouse state structure */
if (This->absolute) {
mstate->lX = rx;
mstate->lY = ry;
mstate->lX = PosX;
mstate->lY = PosY;
} else {
mstate->lX = rx - This->win_centerX;
mstate->lY = ry - This->win_centerY;
mstate->lX = PosX - This->win_centerX;
mstate->lY = PosY - This->win_centerY;
if ((mstate->lX != 0) || (mstate->lY != 0))
This->need_warp = 1;
}
mstate->lZ = 0;
mstate->rgbButtons[0] = (state & MK_LBUTTON ? 0xFF : 0x00);
mstate->rgbButtons[1] = (state & MK_RBUTTON ? 0xFF : 0x00);
mstate->rgbButtons[2] = (state & MK_MBUTTON ? 0xFF : 0x00);
/* WARNING : this supposes that DInput takes into account the 'SwapButton' option */
mstate->rgbButtons[0] = (MouseButtonsStates[0] ? 0xFF : 0x00);
mstate->rgbButtons[1] = (MouseButtonsStates[1] ? 0xFF : 0x00);
mstate->rgbButtons[2] = (MouseButtonsStates[2] ? 0xFF : 0x00);
mstate->rgbButtons[3] = 0x00;
/* Check if we need to do a mouse warping */

View File

@ -44,12 +44,5 @@ BOOL EVENT_CheckFocus(void)
return EVENT_Driver->pCheckFocus();
}
/***********************************************************************
* EVENT_QueryPointer
*/
BOOL EVENT_QueryPointer(DWORD *posX, DWORD *posY, DWORD *state)
{
return EVENT_Driver->pQueryPointer(posX, posY, state);
}

View File

@ -37,7 +37,7 @@ DECLARE_DEBUG_CHANNEL(keyboard)
DECLARE_DEBUG_CHANNEL(win)
static BOOL InputEnabled = TRUE;
static BOOL SwappedButtons = FALSE;
BOOL SwappedButtons = FALSE;
BOOL MouseButtonsStates[3];
BOOL AsyncMouseButtonsStates[3];
@ -45,6 +45,9 @@ BYTE InputKeyStateTable[256];
BYTE QueueKeyStateTable[256];
BYTE AsyncKeyStateTable[256];
/* Storage for the USER-maintained mouse positions */
DWORD PosX, PosY;
typedef union
{
struct
@ -67,7 +70,7 @@ typedef union
void WINAPI keybd_event( BYTE bVk, BYTE bScan,
DWORD dwFlags, DWORD dwExtraInfo )
{
DWORD posX, posY, time, extra;
DWORD time, extra;
WORD message;
KEYLP keylp;
keylp.lp2 = 0;
@ -84,19 +87,13 @@ void WINAPI keybd_event( BYTE bVk, BYTE bScan,
&& ((WINE_KEYBDEVENT *)dwExtraInfo)->magic == WINE_KEYBDEVENT_MAGIC )
{
WINE_KEYBDEVENT *wke = (WINE_KEYBDEVENT *)dwExtraInfo;
posX = wke->posX;
posY = wke->posY;
time = wke->time;
extra = 0;
}
else
{
DWORD keyState;
time = GetTickCount();
extra = dwExtraInfo;
if ( !EVENT_QueryPointer( &posX, &posY, &keyState ))
return;
}
@ -140,7 +137,7 @@ void WINAPI keybd_event( BYTE bVk, BYTE bScan,
TRACE_(key)(" wParam=%04X, lParam=%08lX\n", bVk, keylp.lp2 );
TRACE_(key)(" InputKeyState=%X\n", InputKeyStateTable[bVk] );
hardware_event( message, bVk, keylp.lp2, posX, posY, time, extra );
hardware_event( message, bVk, keylp.lp2, PosX, PosY, time, extra );
}
/***********************************************************************
@ -163,10 +160,39 @@ void WINAPI WIN16_keybd_event( CONTEXT86 *context )
void WINAPI mouse_event( DWORD dwFlags, DWORD dx, DWORD dy,
DWORD cButtons, DWORD dwExtraInfo )
{
DWORD posX, posY, keyState, time, extra;
DWORD time, extra;
DWORD keyState;
if (!InputEnabled) return;
if ( dwFlags & MOUSEEVENTF_MOVE )
{
if ( dwFlags & MOUSEEVENTF_ABSOLUTE )
{
PosX = (dx * GetSystemMetrics(SM_CXSCREEN)) >> 16;
PosY = (dy * GetSystemMetrics(SM_CYSCREEN)) >> 16;
}
else
{
int width = GetSystemMetrics(SM_CXSCREEN);
int height = GetSystemMetrics(SM_CYSCREEN);
long posX = (long) PosX, posY = (long) PosY;
/* dx and dy can be negative numbers for relative movements */
posX += (long) dx;
posY += (long) dy;
/* Clip to the current screen size */
if (posX < 0) PosX = 0;
else if (posX >= width) PosX = width - 1;
else PosX = posX;
if (posY < 0) PosY = 0;
else if (posY >= height) PosY = height - 1;
else PosY = posY;
}
}
/*
* If we are called by the Wine mouse driver, use the additional
* info pointed to by the dwExtraInfo argument.
@ -177,79 +203,73 @@ void WINAPI mouse_event( DWORD dwFlags, DWORD dx, DWORD dy,
&& ((WINE_MOUSEEVENT *)dwExtraInfo)->magic == WINE_MOUSEEVENT_MAGIC )
{
WINE_MOUSEEVENT *wme = (WINE_MOUSEEVENT *)dwExtraInfo;
keyState = wme->keyState;
time = wme->time;
extra = (DWORD)wme->hWnd;
keyState = wme->keyState;
assert( dwFlags & MOUSEEVENTF_ABSOLUTE );
posX = (dx * GetSystemMetrics(SM_CXSCREEN)) >> 16;
posY = (dy * GetSystemMetrics(SM_CYSCREEN)) >> 16;
if (keyState != GET_KEYSTATE()) {
/* We need to update the keystate with what X provides us */
MouseButtonsStates[SwappedButtons ? 2 : 0] = (keyState & MK_LBUTTON ? TRUE : FALSE);
MouseButtonsStates[SwappedButtons ? 0 : 2] = (keyState & MK_RBUTTON ? TRUE : FALSE);
MouseButtonsStates[1] = (keyState & MK_MBUTTON ? TRUE : FALSE);
InputKeyStateTable[VK_SHIFT] = (keyState & MK_SHIFT ? 0x80 : 0);
InputKeyStateTable[VK_CONTROL] = (keyState & MK_CONTROL ? 0x80 : 0);
}
}
else
{
time = GetTickCount();
extra = dwExtraInfo;
keyState = GET_KEYSTATE();
if ( !EVENT_QueryPointer( &posX, &posY, &keyState ))
return;
if ( dwFlags & MOUSEEVENTF_MOVE )
{
if ( dwFlags & MOUSEEVENTF_ABSOLUTE )
{
posX = (dx * GetSystemMetrics(SM_CXSCREEN)) >> 16;
posY = (dy * GetSystemMetrics(SM_CYSCREEN)) >> 16;
}
else
{
posX += dx;
posY += dy;
}
/* We have to actually move the cursor */
SetCursorPos( posX, posY );
}
if ( dwFlags & MOUSEEVENTF_MOVE )
{
/* We have to actually move the cursor */
SetCursorPos( PosX, PosY );
}
}
if ( dwFlags & MOUSEEVENTF_MOVE )
{
hardware_event( WM_MOUSEMOVE,
keyState, 0L, posX, posY, time, extra );
keyState, 0L, PosX, PosY, time, extra );
}
if ( dwFlags & (!SwappedButtons? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_RIGHTDOWN) )
{
MouseButtonsStates[0] = AsyncMouseButtonsStates[0] = TRUE;
hardware_event( WM_LBUTTONDOWN,
keyState, 0L, posX, posY, time, extra );
keyState, 0L, PosX, PosY, time, extra );
}
if ( dwFlags & (!SwappedButtons? MOUSEEVENTF_LEFTUP : MOUSEEVENTF_RIGHTUP) )
{
MouseButtonsStates[0] = FALSE;
hardware_event( WM_LBUTTONUP,
keyState, 0L, posX, posY, time, extra );
keyState, 0L, PosX, PosY, time, extra );
}
if ( dwFlags & (!SwappedButtons? MOUSEEVENTF_RIGHTDOWN : MOUSEEVENTF_LEFTDOWN) )
{
MouseButtonsStates[2] = AsyncMouseButtonsStates[2] = TRUE;
hardware_event( WM_RBUTTONDOWN,
keyState, 0L, posX, posY, time, extra );
keyState, 0L, PosX, PosY, time, extra );
}
if ( dwFlags & (!SwappedButtons? MOUSEEVENTF_RIGHTUP : MOUSEEVENTF_LEFTUP) )
{
MouseButtonsStates[2] = FALSE;
hardware_event( WM_RBUTTONUP,
keyState, 0L, posX, posY, time, extra );
keyState, 0L, PosX, PosY, time, extra );
}
if ( dwFlags & MOUSEEVENTF_MIDDLEDOWN )
{
MouseButtonsStates[1] = AsyncMouseButtonsStates[1] = TRUE;
hardware_event( WM_MBUTTONDOWN,
keyState, 0L, posX, posY, time, extra );
keyState, 0L, PosX, PosY, time, extra );
}
if ( dwFlags & MOUSEEVENTF_MIDDLEUP )
{
MouseButtonsStates[1] = FALSE;
hardware_event( WM_MBUTTONUP,
keyState, 0L, posX, posY, time, extra );
keyState, 0L, PosX, PosY, time, extra );
}
}

View File

@ -46,8 +46,14 @@ WORD WINAPI MOUSE_Inquire(LPMOUSEINFO mouseInfo)
*/
VOID WINAPI MOUSE_Enable(LPMOUSE_EVENT_PROC lpMouseEventProc)
{
static BOOL initDone = FALSE;
THUNK_Free( (FARPROC)DefMouseEventProc );
DefMouseEventProc = lpMouseEventProc;
/* Now initialize the mouse driver */
if (initDone == FALSE) MOUSE_Driver->pInit();
initDone = TRUE;
}
static VOID WINAPI MOUSE_CallMouseEventProc( FARPROC16 proc,
@ -102,14 +108,18 @@ void MOUSE_SendEvent( DWORD mouseStatus, DWORD posX, DWORD posY,
TRACE("(%04lX,%ld,%ld)\n", mouseStatus, posX, posY );
mouseStatus |= MOUSEEVENTF_ABSOLUTE;
posX = (((long)posX << 16) + width-1) / width;
posY = (((long)posY << 16) + height-1) / height;
if (mouseStatus & MOUSEEVENTF_MOVE) {
if (mouseStatus & MOUSEEVENTF_ABSOLUTE) {
/* Relative mouse movements seems not to be scaled as absolute ones */
posX = (((long)posX << 16) + width-1) / width;
posY = (((long)posY << 16) + height-1) / height;
}
}
wme.magic = WINE_MOUSEEVENT_MAGIC;
wme.keyState = keyState;
wme.time = time;
wme.hWnd = hWnd;
wme.keyState = keyState;
bOldWarpPointer = MOUSE_Driver->pEnableWarpPointer(FALSE);
/* To avoid deadlocks, we have to suspend all locks on windows structures

View File

@ -29,23 +29,6 @@ BOOL TTYDRV_EVENT_CheckFocus(void)
return TRUE;
}
/***********************************************************************
* TTYDRV_EVENT_QueryPointer
*/
BOOL TTYDRV_EVENT_QueryPointer(DWORD *posX, DWORD *posY, DWORD *state)
{
if(posX)
*posX = 0;
if(posY)
*posY = 0;
if(state)
*state = 0;
return TRUE;
}
/***********************************************************************
* TTYDRV_EVENT_UserRepaintDisable
*/

View File

@ -45,7 +45,6 @@ EVENT_DRIVER TTYDRV_EVENT_Driver =
TTYDRV_EVENT_Init,
TTYDRV_EVENT_Synchronize,
TTYDRV_EVENT_CheckFocus,
TTYDRV_EVENT_QueryPointer,
TTYDRV_EVENT_UserRepaintDisable
};
@ -79,6 +78,7 @@ MONITOR_DRIVER TTYDRV_MONITOR_Driver =
MOUSE_DRIVER TTYDRV_MOUSE_Driver =
{
TTYDRV_MOUSE_Init,
TTYDRV_MOUSE_SetCursor,
TTYDRV_MOUSE_MoveCursor,
TTYDRV_MOUSE_EnableWarpPointer

View File

@ -27,3 +27,10 @@ BOOL TTYDRV_MOUSE_EnableWarpPointer(BOOL bEnable)
{
return TRUE;
}
/***********************************************************************
* TTYDRV_MOUSE_Init
*/
void TTYDRV_MOUSE_Init()
{
}

View File

@ -23,6 +23,7 @@
#include "debugtools.h"
#include "local.h"
#include "ldt.h"
#include "input.h"
DEFAULT_DEBUG_CHANNEL(win)
@ -2830,17 +2831,12 @@ Pos: /* -----------------------------------------------------------------------
if (!GetCapture() && ((wndPtr->dwStyle & WS_VISIBLE) || (flags & SWP_HIDEWINDOW)))
{
/* Simulate a mouse event to set the cursor */
DWORD posX, posY, keyState;
int iWndsLocks = WIN_SuspendWndsLock();
if ( EVENT_QueryPointer( &posX, &posY, &keyState ) )
{
int iWndsLocks = WIN_SuspendWndsLock();
hardware_event( WM_MOUSEMOVE, GET_KEYSTATE(), 0,
PosX, PosY, GetTickCount(), 0 );
hardware_event( WM_MOUSEMOVE, keyState, 0,
posX, posY, GetTickCount(), 0 );
WIN_RestoreWndsLock(iWndsLocks);
}
WIN_RestoreWndsLock(iWndsLocks);
}
wndTemp = WIN_GetDesktop();

View File

@ -112,6 +112,9 @@ static void EVENT_GetGeometry( Window win, int *px, int *py,
static BOOL bUserRepaintDisabled = TRUE;
/* Static used for the current input method */
static INPUT_TYPE current_input_type = X11DRV_INPUT_ABSOLUTE;
static BOOL in_transition = FALSE; /* This is not used as for today */
/***********************************************************************
* EVENT_Init
@ -257,8 +260,11 @@ static void EVENT_ProcessEvent( XEvent *event )
problems if the event order is important. I'm not yet seen
of any problems. Jon 7/6/96.
*/
while (TSXCheckTypedWindowEvent(display,((XAnyEvent *)event)->window,
MotionNotify, event));
if ((current_input_type == X11DRV_INPUT_ABSOLUTE) &&
(in_transition == FALSE))
/* Only cumulate events if in absolute mode */
while (TSXCheckTypedWindowEvent(display,((XAnyEvent *)event)->window,
MotionNotify, event));
EVENT_MotionNotify( hWnd, (XMotionEvent*)event );
break;
@ -500,12 +506,12 @@ static HWND EVENT_QueryZOrder( HWND hWndCheck)
}
/***********************************************************************
* EVENT_XStateToKeyState
* X11DRV_EVENT_XStateToKeyState
*
* Translate a X event state (Button1Mask, ShiftMask, etc...) to
* a Windows key state (MK_SHIFT, MK_CONTROL, etc...)
*/
static WORD EVENT_XStateToKeyState( int state )
WORD X11DRV_EVENT_XStateToKeyState( int state )
{
int kstate = 0;
@ -517,29 +523,6 @@ static WORD EVENT_XStateToKeyState( int state )
return kstate;
}
/***********************************************************************
* X11DRV_EVENT_QueryPointer
*/
BOOL X11DRV_EVENT_QueryPointer(DWORD *posX, DWORD *posY, DWORD *state)
{
Window root, child;
int rootX, rootY, winX, winY;
unsigned int xstate;
if (!TSXQueryPointer( display, X11DRV_GetXRootWindow(), &root, &child,
&rootX, &rootY, &winX, &winY, &xstate ))
return FALSE;
if(posX)
*posX = (DWORD)winX;
if(posY)
*posY = (DWORD)winY;
if(state)
*state = EVENT_XStateToKeyState( xstate );
return TRUE;
}
/***********************************************************************
* EVENT_Expose
*/
@ -605,16 +588,24 @@ static void EVENT_Key( HWND hWnd, XKeyEvent *event )
*/
static void EVENT_MotionNotify( HWND hWnd, XMotionEvent *event )
{
WND *pWnd = WIN_FindWndPtr(hWnd);
int xOffset = pWnd? pWnd->rectWindow.left : 0;
int yOffset = pWnd? pWnd->rectWindow.top : 0;
WIN_ReleaseWndPtr(pWnd);
if (current_input_type == X11DRV_INPUT_ABSOLUTE) {
WND *pWnd = WIN_FindWndPtr(hWnd);
int xOffset = pWnd? pWnd->rectWindow.left : 0;
int yOffset = pWnd? pWnd->rectWindow.top : 0;
WIN_ReleaseWndPtr(pWnd);
MOUSE_SendEvent( MOUSEEVENTF_MOVE,
xOffset + event->x, yOffset + event->y,
EVENT_XStateToKeyState( event->state ),
event->time - MSG_WineStartTicks,
hWnd);
MOUSE_SendEvent( MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE,
xOffset + event->x, yOffset + event->y,
X11DRV_EVENT_XStateToKeyState( event->state ),
event->time - MSG_WineStartTicks,
hWnd);
} else {
MOUSE_SendEvent( MOUSEEVENTF_MOVE,
event->x_root, event->y_root,
X11DRV_EVENT_XStateToKeyState( event->state ),
event->time - MSG_WineStartTicks,
hWnd);
}
}
@ -639,7 +630,7 @@ static void EVENT_ButtonPress( HWND hWnd, XButtonEvent *event )
/*
* Get the compatible keystate
*/
keystate = EVENT_XStateToKeyState( event->state );
keystate = X11DRV_EVENT_XStateToKeyState( event->state );
/*
* Make sure that the state of the button that was just
@ -686,7 +677,7 @@ static void EVENT_ButtonRelease( HWND hWnd, XButtonEvent *event )
/*
* Get the compatible keystate
*/
keystate = EVENT_XStateToKeyState( event->state );
keystate = X11DRV_EVENT_XStateToKeyState( event->state );
/*
* Make sure that the state of the button that was just
@ -1775,5 +1766,18 @@ void EVENT_UnmapNotify( HWND hWnd, XUnmapEvent *event )
WIN_ReleaseWndPtr(pWnd);
}
/**********************************************************************
* X11DRV_EVENT_SetInputMehod
*/
INPUT_TYPE X11DRV_EVENT_SetInputMehod(INPUT_TYPE type)
{
INPUT_TYPE prev = current_input_type;
/* Flag not used yet */
in_transition = FALSE;
current_input_type = type;
return prev;
}
#endif /* !defined(X_DISPLAY_MISSING) */

View File

@ -49,7 +49,6 @@ EVENT_DRIVER X11DRV_EVENT_Driver =
X11DRV_EVENT_Init,
X11DRV_EVENT_Synchronize,
X11DRV_EVENT_CheckFocus,
X11DRV_EVENT_QueryPointer,
X11DRV_EVENT_UserRepaintDisable
};
@ -83,6 +82,7 @@ MONITOR_DRIVER X11DRV_MONITOR_Driver =
MOUSE_DRIVER X11DRV_MOUSE_Driver =
{
X11DRV_MOUSE_Init,
X11DRV_MOUSE_SetCursor,
X11DRV_MOUSE_MoveCursor,
X11DRV_MOUSE_EnableWarpPointer

View File

@ -253,4 +253,26 @@ BOOL X11DRV_MOUSE_EnableWarpPointer(BOOL bEnable)
return bOldEnable;
}
/***********************************************************************
* X11DRV_MOUSE_Init
*/
void X11DRV_MOUSE_Init()
{
Window root, child;
int root_x, root_y, child_x, child_y;
unsigned int KeyState;
/* Get the current mouse position and simulate an absolute mouse
movement to initialize the mouse global variables */
TSXQueryPointer( display, X11DRV_GetXRootWindow(), &root, &child,
&root_x, &root_y, &child_x, &child_y, &KeyState);
MOUSE_SendEvent(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE,
root_x, root_y,
X11DRV_EVENT_XStateToKeyState(KeyState),
GetTickCount(),
0);
}
#endif /* !defined(X_DISPLAY_MISSING) */