summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon TURNEY <jon.turney@dronecode.org.uk>2013-02-21 17:12:17 +0000
committerJon TURNEY <jon.turney@dronecode.org.uk>2013-07-23 23:59:27 +0100
commit71b5f56302bbd8be62f63f0dd62cbcd33aab3ac5 (patch)
treefe1ac084cb57bdcbf163b60d739283a3f8a09b93
parentcf9c777ee094d660e0c95559373fd23ee910362e (diff)
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>
-rw-r--r--hw/xwin/win.h8
-rw-r--r--hw/xwin/winmessages.h2
-rw-r--r--hw/xwin/winmouse.c26
-rw-r--r--hw/xwin/winmultiwindowwndproc.c12
-rw-r--r--hw/xwin/winwin32rootlesswndproc.c9
-rw-r--r--hw/xwin/winwndproc.c16
6 files changed, 55 insertions, 18 deletions
diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index 182e96b6c..ce89348fe 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -42,6 +42,11 @@
#define YES 1
#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 */
#ifndef CYGDEBUG
#define CYGDEBUG NO
@@ -449,6 +454,7 @@ typedef struct _winPrivScreenRec {
Bool fBadDepth;
int iDeltaZ;
+ int iDeltaV;
int iConnectedClients;
@@ -975,7 +981,7 @@ int
winMouseProc(DeviceIntPtr pDeviceInt, int iState);
int
- winMouseWheel(ScreenPtr pScreen, int iDeltaZ);
+ winMouseWheel(int *iTotalDeltaZ, int iDeltaZ, int iButtonUp, int iButtonDown);
void
winMouseButtonsSendEvent(int iEventType, int iButton);
diff --git a/hw/xwin/winmessages.h b/hw/xwin/winmessages.h
index 3d3fab274..8282f8b06 100644
--- a/hw/xwin/winmessages.h
+++ b/hw/xwin/winmessages.h
@@ -529,7 +529,7 @@ static const char *MESSAGE_NAMES[1024] = {
"WM_XBUTTONDOWN",
"WM_XBUTTONUP",
"WM_XBUTTONDBLCLK",
- "526",
+ "WM_MOUSEHWHEEL",
"527",
"WM_PARENTNOTIFY",
"WM_ENTERMENULOOP",
diff --git a/hw/xwin/winmouse.c b/hw/xwin/winmouse.c
index da067cde0..bbe21cba6 100644
--- a/hw/xwin/winmouse.c
+++ b/hw/xwin/winmouse.c
@@ -145,20 +145,16 @@ winMouseProc(DeviceIntPtr pDeviceInt, int iState)
/* Handle the mouse wheel */
int
-winMouseWheel(ScreenPtr pScreen, int iDeltaZ)
+winMouseWheel(int *iTotalDeltaZ, int iDeltaZ, int iButtonUp, int iButtonDown)
{
- winScreenPriv(pScreen);
- int button; /* Button4 or Button5 */
-
- /* Button4 = WheelUp */
- /* Button5 = WheelDown */
+ int button;
/* Do we have any previous delta stored? */
- if ((pScreenPriv->iDeltaZ > 0 && iDeltaZ > 0)
- || (pScreenPriv->iDeltaZ < 0 && iDeltaZ < 0)) {
+ if ((*iTotalDeltaZ > 0 && iDeltaZ > 0)
+ || (*iTotalDeltaZ < 0 && iDeltaZ < 0)) {
/* Previous delta and of same sign as current delta */
- iDeltaZ += pScreenPriv->iDeltaZ;
- pScreenPriv->iDeltaZ = 0;
+ iDeltaZ += *iTotalDeltaZ;
+ *iTotalDeltaZ = 0;
}
else {
/*
@@ -167,7 +163,7 @@ winMouseWheel(ScreenPtr pScreen, int iDeltaZ)
* as blindly setting takes just as much time
* as checking, then setting if necessary :)
*/
- pScreenPriv->iDeltaZ = 0;
+ *iTotalDeltaZ = 0;
}
/*
@@ -175,7 +171,7 @@ winMouseWheel(ScreenPtr pScreen, int 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 */
iDeltaZ /= WHEEL_DELTA;
@@ -186,16 +182,16 @@ winMouseWheel(ScreenPtr pScreen, int iDeltaZ)
* we will store the wheel delta until the threshold
* has been reached.
*/
- pScreenPriv->iDeltaZ = iDeltaZ;
+ *iTotalDeltaZ = iDeltaZ;
return 0;
}
/* Set the button to indicate up or down wheel delta */
if (iDeltaZ > 0) {
- button = Button4;
+ button = iButtonUp;
}
else {
- button = Button5;
+ button = iButtonDown;
}
/*
diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c
index da7914ab7..9292e73ca 100644
--- a/hw/xwin/winmultiwindowwndproc.c
+++ b/hw/xwin/winmultiwindowwndproc.c
@@ -684,6 +684,18 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
else
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:
if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
break;
diff --git a/hw/xwin/winwin32rootlesswndproc.c b/hw/xwin/winwin32rootlesswndproc.c
index 9c282ecb4..be2958338 100644
--- a/hw/xwin/winwin32rootlesswndproc.c
+++ b/hw/xwin/winwin32rootlesswndproc.c
@@ -667,6 +667,15 @@ winMWExtWMWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
SendMessage(hwndScreen, message, wParam, lParam);
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:
#if CYGMULTIWINDOW_DEBUG
winDebug("winMWExtWMWindowProc - WM_MOUSEACTIVATE\n");
diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c
index 7af222ca5..c73a75c6f 100644
--- a/hw/xwin/winwndproc.c
+++ b/hw/xwin/winwndproc.c
@@ -976,7 +976,20 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
#if CYGDEBUG
winDebug("winWindowProc - WM_MOUSEWHEEL\n");
#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;
case WM_SETFOCUS:
@@ -1147,6 +1160,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
/* Clear any lingering wheel delta */
s_pScreenPriv->iDeltaZ = 0;
+ s_pScreenPriv->iDeltaV = 0;
/* Reshow the Windows mouse cursor if we are being deactivated */
if (g_fSoftwareCursor && LOWORD(wParam) == WA_INACTIVE && !g_fCursor) {