From d5f5927f682abed3f77db64a5f6467c0847cf4e9 Mon Sep 17 00:00:00 2001 From: Constantin Kaplinsky Date: Thu, 14 Sep 2006 05:14:43 +0000 Subject: [PATCH] Fixed passing of mouse wheel events. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2096 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- win/vncviewer/DesktopWindow.cxx | 140 +++++++++++++++++--------------- win/vncviewer/DesktopWindow.h | 4 + 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; igetRect().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; igetRect().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; -- 2.39.5