Fixed mouse position processing for use with a touchscreen.
This commit is contained in:
parent
cde7d63bd5
commit
6b8cedfd62
|
@ -159,32 +159,29 @@ static void queue_kbd_event( const KEYBDINPUT *ki )
|
|||
*/
|
||||
static void queue_mouse_event( const MOUSEINPUT *mi, WORD keystate )
|
||||
{
|
||||
if (mi->dwFlags & MOUSEEVENTF_MOVE)
|
||||
if (mi->dwFlags & MOUSEEVENTF_ABSOLUTE)
|
||||
{
|
||||
if (mi->dwFlags & MOUSEEVENTF_ABSOLUTE)
|
||||
{
|
||||
PosX = (mi->dx * GetSystemMetrics(SM_CXSCREEN)) >> 16;
|
||||
PosY = (mi->dy * GetSystemMetrics(SM_CYSCREEN)) >> 16;
|
||||
}
|
||||
else
|
||||
{
|
||||
int width = GetSystemMetrics(SM_CXSCREEN);
|
||||
int height = GetSystemMetrics(SM_CYSCREEN);
|
||||
long posX = (long) PosX, posY = (long) PosY;
|
||||
PosX = (mi->dx * GetSystemMetrics(SM_CXSCREEN)) >> 16;
|
||||
PosY = (mi->dy * GetSystemMetrics(SM_CYSCREEN)) >> 16;
|
||||
}
|
||||
else if (mi->dwFlags & MOUSEEVENTF_MOVE)
|
||||
{
|
||||
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)mi->dx;
|
||||
posY += (long)mi->dy;
|
||||
/* dx and dy can be negative numbers for relative movements */
|
||||
posX += (long)mi->dx;
|
||||
posY += (long)mi->dy;
|
||||
|
||||
/* Clip to the current screen size */
|
||||
if (posX < 0) PosX = 0;
|
||||
else if (posX >= width) PosX = width - 1;
|
||||
else PosX = posX;
|
||||
/* 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 (posY < 0) PosY = 0;
|
||||
else if (posY >= height) PosY = height - 1;
|
||||
else PosY = posY;
|
||||
}
|
||||
|
||||
if (mi->dwFlags & MOUSEEVENTF_MOVE)
|
||||
|
|
|
@ -477,7 +477,7 @@ static void EVENT_ButtonPress( HWND hWnd, XButtonEvent *event )
|
|||
break;
|
||||
}
|
||||
|
||||
X11DRV_SendEvent( statusCodes[buttonNum], pt.x, pt.y,
|
||||
X11DRV_SendEvent( statusCodes[buttonNum] | MOUSEEVENTF_ABSOLUTE, pt.x, pt.y,
|
||||
keystate, wData, event->time - X11DRV_server_startticks, hWnd);
|
||||
}
|
||||
|
||||
|
@ -518,7 +518,7 @@ static void EVENT_ButtonRelease( HWND hWnd, XButtonEvent *event )
|
|||
default:
|
||||
return;
|
||||
}
|
||||
X11DRV_SendEvent( statusCodes[buttonNum], pt.x, pt.y,
|
||||
X11DRV_SendEvent( statusCodes[buttonNum] | MOUSEEVENTF_ABSOLUTE, pt.x, pt.y,
|
||||
keystate, 0, event->time - X11DRV_server_startticks, hWnd);
|
||||
}
|
||||
|
||||
|
|
|
@ -292,8 +292,6 @@ void X11DRV_InitMouse( LPMOUSE_EVENT_PROC proc )
|
|||
void X11DRV_SendEvent( DWORD mouseStatus, DWORD posX, DWORD posY,
|
||||
WORD keyState, DWORD data, DWORD time, HWND hWnd )
|
||||
{
|
||||
int width = GetSystemMetrics( SM_CXSCREEN );
|
||||
int height = GetSystemMetrics( SM_CYSCREEN );
|
||||
int iWndsLocks;
|
||||
WINE_MOUSEEVENT wme;
|
||||
|
||||
|
@ -301,19 +299,20 @@ void X11DRV_SendEvent( DWORD mouseStatus, DWORD posX, DWORD posY,
|
|||
|
||||
TRACE("(%04lX,%ld,%ld)\n", mouseStatus, posX, posY );
|
||||
|
||||
if (mouseStatus & MOUSEEVENTF_MOVE) {
|
||||
if (mouseStatus & MOUSEEVENTF_ABSOLUTE) {
|
||||
if (mouseStatus & MOUSEEVENTF_ABSOLUTE)
|
||||
{
|
||||
int width = GetSystemMetrics( SM_CXSCREEN );
|
||||
int height = GetSystemMetrics( SM_CYSCREEN );
|
||||
/* 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.time = time;
|
||||
wme.hWnd = hWnd;
|
||||
wme.keyState = keyState;
|
||||
|
||||
|
||||
InterlockedDecrement( &X11DRV_MOUSE_WarpPointer );
|
||||
/* To avoid deadlocks, we have to suspend all locks on windows structures
|
||||
before the program control is passed to the mouse driver */
|
||||
|
|
Loading…
Reference in New Issue