summaryrefslogtreecommitdiffstats
path: root/win/vncviewer
diff options
context:
space:
mode:
authorConstantin Kaplinsky <const@tightvnc.com>2006-09-14 05:14:43 +0000
committerConstantin Kaplinsky <const@tightvnc.com>2006-09-14 05:14:43 +0000
commitd5f5927f682abed3f77db64a5f6467c0847cf4e9 (patch)
treef7929ba15590ba246494b7da0652a149826ef7c5 /win/vncviewer
parentadc4537ced5278db0431f5b36c74f49649c2aaec (diff)
downloadtigervnc-d5f5927f682abed3f77db64a5f6467c0847cf4e9.tar.gz
tigervnc-d5f5927f682abed3f77db64a5f6467c0847cf4e9.zip
Fixed passing of mouse wheel events.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2096 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'win/vncviewer')
-rw-r--r--win/vncviewer/DesktopWindow.cxx140
-rw-r--r--win/vncviewer/DesktopWindow.h4
2 files changed, 79 insertions, 65 deletions
diff --git a/win/vncviewer/DesktopWindow.cxx b/win/vncviewer/DesktopWindow.cxx
index 0feb24ee..313b756d 100644
--- a/win/vncviewer/DesktopWindow.cxx
+++ b/win/vncviewer/DesktopWindow.cxx
@@ -616,6 +616,14 @@ DesktopWindow::processMessage(UINT msg, WPARAM wParam, LPARAM lParam) {
kbd.keyEvent(callback, wParam, lParam, (msg == WM_KEYDOWN) || (msg == WM_SYSKEYDOWN));
return 0;
+ // -=- Handle mouse wheel scroll events
+
+#ifdef WM_MOUSEWHEEL
+ case WM_MOUSEWHEEL:
+ processMouseMessage(msg, wParam, lParam);
+ break;
+#endif
+
// -=- Handle the window closing
case WM_CLOSE:
@@ -756,81 +764,83 @@ DesktopWindow::processFrameMessage(UINT msg, WPARAM wParam, LPARAM lParam) {
case WM_LBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_RBUTTONDOWN:
-#ifdef WM_MOUSEWHEEL
- case WM_MOUSEWHEEL:
-#endif
- if (has_focus)
- {
- if (!trackingMouseLeave) {
- TRACKMOUSEEVENT tme;
- tme.cbSize = sizeof(TRACKMOUSEEVENT);
- tme.dwFlags = TME_LEAVE;
- tme.hwndTrack = frameHandle;
- _TrackMouseEvent(&tme);
- trackingMouseLeave = true;
- }
- int mask = 0;
- if (LOWORD(wParam) & MK_LBUTTON) mask |= 1;
- if (LOWORD(wParam) & MK_MBUTTON) mask |= 2;
- if (LOWORD(wParam) & MK_RBUTTON) mask |= 4;
+ processMouseMessage(msg, wParam, lParam);
+ break;
+ }
-#ifdef WM_MOUSEWHEEL
- if (msg == WM_MOUSEWHEEL) {
- int delta = (short)HIWORD(wParam);
- int repeats = (abs(delta)+119) / 120;
- int wheelMask = (delta > 0) ? 8 : 16;
- vlog.debug("repeats %d, mask %d\n",repeats,wheelMask);
- for (int i=0; i<repeats; i++) {
- ptr.pointerEvent(callback, oldpos, mask | wheelMask);
- ptr.pointerEvent(callback, oldpos, mask);
- }
- } else {
-#endif
- Point clientPos = Point(LOWORD(lParam), HIWORD(lParam));
- Point p = clientToDesktop(clientPos);
-
- // If the mouse is not within the server buffer area, do nothing
- cursorInBuffer = buffer->getRect().contains(p);
- if (!cursorInBuffer) {
- cursorOutsideBuffer();
- break;
- }
+ return rfb::win32::SafeDefWindowProc(frameHandle, msg, wParam, lParam);
+}
- // If we're locally rendering the cursor then redraw it
- if (cursorAvailable) {
- // - Render the cursor!
- if (!p.equals(cursorPos)) {
- hideLocalCursor();
- cursorPos = p;
- showLocalCursor();
- if (cursorVisible)
- hideSystemCursor();
- }
- }
+void
+DesktopWindow::processMouseMessage(UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ if (!has_focus) {
+ cursorOutsideBuffer();
+ return;
+ }
- // If we are doing bump-scrolling then try that first...
- if (processBumpScroll(clientPos))
- break;
+ if (!trackingMouseLeave) {
+ TRACKMOUSEEVENT tme;
+ tme.cbSize = sizeof(TRACKMOUSEEVENT);
+ tme.dwFlags = TME_LEAVE;
+ tme.hwndTrack = frameHandle;
+ _TrackMouseEvent(&tme);
+ trackingMouseLeave = true;
+ }
+ int mask = 0;
+ if (LOWORD(wParam) & MK_LBUTTON) mask |= 1;
+ if (LOWORD(wParam) & MK_MBUTTON) mask |= 2;
+ if (LOWORD(wParam) & MK_RBUTTON) mask |= 4;
- // Send a pointer event to the server
- oldpos = p;
- if (buffer->isScaling()) {
- p.x /= buffer->getScaleRatio();
- p.y /= buffer->getScaleRatio();
- }
- ptr.pointerEvent(callback, p, mask);
#ifdef WM_MOUSEWHEEL
- }
+ if (msg == WM_MOUSEWHEEL) {
+ int delta = (short)HIWORD(wParam);
+ int repeats = (abs(delta)+119) / 120;
+ int wheelMask = (delta > 0) ? 8 : 16;
+ vlog.debug("repeats %d, mask %d\n",repeats,wheelMask);
+ for (int i=0; i<repeats; i++) {
+ ptr.pointerEvent(callback, oldpos, mask | wheelMask);
+ ptr.pointerEvent(callback, oldpos, mask);
+ }
+ } else {
#endif
- } else {
+ Point clientPos = Point(LOWORD(lParam), HIWORD(lParam));
+ Point p = clientToDesktop(clientPos);
+
+ // If the mouse is not within the server buffer area, do nothing
+ cursorInBuffer = buffer->getRect().contains(p);
+ if (!cursorInBuffer) {
cursorOutsideBuffer();
+ return;
}
- break;
- }
- return rfb::win32::SafeDefWindowProc(frameHandle, msg, wParam, lParam);
-}
+ // If we're locally rendering the cursor then redraw it
+ if (cursorAvailable) {
+ // - Render the cursor!
+ if (!p.equals(cursorPos)) {
+ hideLocalCursor();
+ cursorPos = p;
+ showLocalCursor();
+ if (cursorVisible)
+ hideSystemCursor();
+ }
+ }
+
+ // If we are doing bump-scrolling then try that first...
+ if (processBumpScroll(clientPos))
+ return;
+ // Send a pointer event to the server
+ oldpos = p;
+ if (buffer->isScaling()) {
+ p.x /= buffer->getScaleRatio();
+ p.y /= buffer->getScaleRatio();
+ }
+ ptr.pointerEvent(callback, p, mask);
+#ifdef WM_MOUSEWHEEL
+ }
+#endif
+}
void
DesktopWindow::hideLocalCursor() {
diff --git a/win/vncviewer/DesktopWindow.h b/win/vncviewer/DesktopWindow.h
index f8d3ac32..6e7a1d0b 100644
--- a/win/vncviewer/DesktopWindow.h
+++ b/win/vncviewer/DesktopWindow.h
@@ -56,6 +56,10 @@ namespace rfb {
// - Window message handling procedure for the framebuffer window
LRESULT processFrameMessage(UINT msg, WPARAM wParam, LPARAM lParam);
+ // - Separate message handling procedure for mouse events
+ // It's called from both processMessage() and processFrameMessage()
+ void processMouseMessage(UINT msg, WPARAM wParam, LPARAM lParam);
+
// - Determine the native pixel format of the window
// This can (and often will) differ from the PixelBuffer format
PixelFormat getNativePF() const;