hw/xwin: Handle WM_MOUSEHWHEEL

Handle WM_MOUSEHWHEEL tilt wheel messages, similarly to WM_MOUSEWHEEL scroll
wheel messages, to generate X button 6 and 7 presses and releases.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
This commit is contained in:
Jon TURNEY 2013-02-21 17:12:17 +00:00
parent cf9c777ee0
commit 71b5f56302
6 changed files with 55 additions and 18 deletions

View File

@ -42,6 +42,11 @@
#define YES 1 #define YES 1
#endif #endif
/* We can handle WM_MOUSEHWHEEL even though _WIN32_WINNT < 0x0600 */
#ifndef WM_MOUSEHWHEEL
#define WM_MOUSEHWHEEL 0x020E
#endif
/* Turn debug messages on or off */ /* Turn debug messages on or off */
#ifndef CYGDEBUG #ifndef CYGDEBUG
#define CYGDEBUG NO #define CYGDEBUG NO
@ -449,6 +454,7 @@ typedef struct _winPrivScreenRec {
Bool fBadDepth; Bool fBadDepth;
int iDeltaZ; int iDeltaZ;
int iDeltaV;
int iConnectedClients; int iConnectedClients;
@ -975,7 +981,7 @@ int
winMouseProc(DeviceIntPtr pDeviceInt, int iState); winMouseProc(DeviceIntPtr pDeviceInt, int iState);
int int
winMouseWheel(ScreenPtr pScreen, int iDeltaZ); winMouseWheel(int *iTotalDeltaZ, int iDeltaZ, int iButtonUp, int iButtonDown);
void void
winMouseButtonsSendEvent(int iEventType, int iButton); winMouseButtonsSendEvent(int iEventType, int iButton);

View File

@ -529,7 +529,7 @@ static const char *MESSAGE_NAMES[1024] = {
"WM_XBUTTONDOWN", "WM_XBUTTONDOWN",
"WM_XBUTTONUP", "WM_XBUTTONUP",
"WM_XBUTTONDBLCLK", "WM_XBUTTONDBLCLK",
"526", "WM_MOUSEHWHEEL",
"527", "527",
"WM_PARENTNOTIFY", "WM_PARENTNOTIFY",
"WM_ENTERMENULOOP", "WM_ENTERMENULOOP",

View File

@ -145,20 +145,16 @@ winMouseProc(DeviceIntPtr pDeviceInt, int iState)
/* Handle the mouse wheel */ /* Handle the mouse wheel */
int int
winMouseWheel(ScreenPtr pScreen, int iDeltaZ) winMouseWheel(int *iTotalDeltaZ, int iDeltaZ, int iButtonUp, int iButtonDown)
{ {
winScreenPriv(pScreen); int button;
int button; /* Button4 or Button5 */
/* Button4 = WheelUp */
/* Button5 = WheelDown */
/* Do we have any previous delta stored? */ /* Do we have any previous delta stored? */
if ((pScreenPriv->iDeltaZ > 0 && iDeltaZ > 0) if ((*iTotalDeltaZ > 0 && iDeltaZ > 0)
|| (pScreenPriv->iDeltaZ < 0 && iDeltaZ < 0)) { || (*iTotalDeltaZ < 0 && iDeltaZ < 0)) {
/* Previous delta and of same sign as current delta */ /* Previous delta and of same sign as current delta */
iDeltaZ += pScreenPriv->iDeltaZ; iDeltaZ += *iTotalDeltaZ;
pScreenPriv->iDeltaZ = 0; *iTotalDeltaZ = 0;
} }
else { else {
/* /*
@ -167,7 +163,7 @@ winMouseWheel(ScreenPtr pScreen, int iDeltaZ)
* as blindly setting takes just as much time * as blindly setting takes just as much time
* as checking, then setting if necessary :) * as checking, then setting if necessary :)
*/ */
pScreenPriv->iDeltaZ = 0; *iTotalDeltaZ = 0;
} }
/* /*
@ -175,7 +171,7 @@ winMouseWheel(ScreenPtr pScreen, int iDeltaZ)
* WHEEL_DELTA * WHEEL_DELTA
*/ */
if (iDeltaZ >= WHEEL_DELTA || (-1 * iDeltaZ) >= WHEEL_DELTA) { if (iDeltaZ >= WHEEL_DELTA || (-1 * iDeltaZ) >= WHEEL_DELTA) {
pScreenPriv->iDeltaZ = 0; *iTotalDeltaZ = 0;
/* Figure out how many whole deltas of the wheel we have */ /* Figure out how many whole deltas of the wheel we have */
iDeltaZ /= WHEEL_DELTA; iDeltaZ /= WHEEL_DELTA;
@ -186,16 +182,16 @@ winMouseWheel(ScreenPtr pScreen, int iDeltaZ)
* we will store the wheel delta until the threshold * we will store the wheel delta until the threshold
* has been reached. * has been reached.
*/ */
pScreenPriv->iDeltaZ = iDeltaZ; *iTotalDeltaZ = iDeltaZ;
return 0; return 0;
} }
/* Set the button to indicate up or down wheel delta */ /* Set the button to indicate up or down wheel delta */
if (iDeltaZ > 0) { if (iDeltaZ > 0) {
button = Button4; button = iButtonUp;
} }
else { else {
button = Button5; button = iButtonDown;
} }
/* /*

View File

@ -684,6 +684,18 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
else else
break; break;
case WM_MOUSEHWHEEL:
if (SendMessage
(hwnd, WM_NCHITTEST, 0,
MAKELONG(GET_X_LPARAM(lParam),
GET_Y_LPARAM(lParam))) == HTCLIENT) {
/* Pass the message to the root window */
SendMessage(hwndScreen, message, wParam, lParam);
return 0;
}
else
break;
case WM_SETFOCUS: case WM_SETFOCUS:
if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
break; break;

View File

@ -667,6 +667,15 @@ winMWExtWMWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
SendMessage(hwndScreen, message, wParam, lParam); SendMessage(hwndScreen, message, wParam, lParam);
return 0; return 0;
case WM_MOUSEHWHEEL:
#if CYGMULTIWINDOW_DEBUG
winDebug("winMWExtWMWindowProc - WM_MOUSEHWHEEL\n");
#endif
/* Pass the message to the root window */
SendMessage(hwndScreen, message, wParam, lParam);
return 0;
case WM_MOUSEACTIVATE: case WM_MOUSEACTIVATE:
#if CYGMULTIWINDOW_DEBUG #if CYGMULTIWINDOW_DEBUG
winDebug("winMWExtWMWindowProc - WM_MOUSEACTIVATE\n"); winDebug("winMWExtWMWindowProc - WM_MOUSEACTIVATE\n");

View File

@ -976,7 +976,20 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
#if CYGDEBUG #if CYGDEBUG
winDebug("winWindowProc - WM_MOUSEWHEEL\n"); winDebug("winWindowProc - WM_MOUSEWHEEL\n");
#endif #endif
winMouseWheel(s_pScreen, GET_WHEEL_DELTA_WPARAM(wParam)); /* Button4 = WheelUp */
/* Button5 = WheelDown */
winMouseWheel(&(s_pScreenPriv->iDeltaZ), GET_WHEEL_DELTA_WPARAM(wParam), Button4, Button5);
break;
case WM_MOUSEHWHEEL:
if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
break;
#if CYGDEBUG
winDebug("winWindowProc - WM_MOUSEHWHEEL\n");
#endif
/* Button7 = TiltRight */
/* Button6 = TiltLeft */
winMouseWheel(&(s_pScreenPriv->iDeltaV), GET_WHEEL_DELTA_WPARAM(wParam), 7, 6);
break; break;
case WM_SETFOCUS: case WM_SETFOCUS:
@ -1147,6 +1160,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
/* Clear any lingering wheel delta */ /* Clear any lingering wheel delta */
s_pScreenPriv->iDeltaZ = 0; s_pScreenPriv->iDeltaZ = 0;
s_pScreenPriv->iDeltaV = 0;
/* Reshow the Windows mouse cursor if we are being deactivated */ /* Reshow the Windows mouse cursor if we are being deactivated */
if (g_fSoftwareCursor && LOWORD(wParam) == WA_INACTIVE && !g_fCursor) { if (g_fSoftwareCursor && LOWORD(wParam) == WA_INACTIVE && !g_fCursor) {