From 6b8cedfd6224499e325973319287089f48220254 Mon Sep 17 00:00:00 2001 From: Brad Campbell Date: Wed, 19 Sep 2001 22:41:22 +0000 Subject: [PATCH] Fixed mouse position processing for use with a touchscreen. --- windows/input.c | 41 +++++++++++++++++++---------------------- windows/x11drv/event.c | 4 ++-- windows/x11drv/mouse.c | 11 +++++------ 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/windows/input.c b/windows/input.c index 9887b6df6eb..7d69b5cb7df 100644 --- a/windows/input.c +++ b/windows/input.c @@ -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) diff --git a/windows/x11drv/event.c b/windows/x11drv/event.c index 01ce5860527..8eb9910be29 100644 --- a/windows/x11drv/event.c +++ b/windows/x11drv/event.c @@ -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); } diff --git a/windows/x11drv/mouse.c b/windows/x11drv/mouse.c index ab8983c74b1..a75f7735ec6 100644 --- a/windows/x11drv/mouse.c +++ b/windows/x11drv/mouse.c @@ -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 */