From 24f5b66cf390bd07db69d829a11c8a8b78b76d92 Mon Sep 17 00:00:00 2001 From: crs Date: Thu, 23 May 2002 15:50:38 +0000 Subject: [PATCH] added support for mouse wheel on X. --- client/CXWindowsSecondaryScreen.cpp | 17 +++++++++++++++-- server/CXWindowsPrimaryScreen.cpp | 8 ++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/client/CXWindowsSecondaryScreen.cpp b/client/CXWindowsSecondaryScreen.cpp index f83d6814..010c4475 100644 --- a/client/CXWindowsSecondaryScreen.cpp +++ b/client/CXWindowsSecondaryScreen.cpp @@ -293,10 +293,23 @@ void CXWindowsSecondaryScreen::mouseMove(SInt32 x, SInt32 y) XSync(display, False); } -void CXWindowsSecondaryScreen::mouseWheel(SInt32) +void CXWindowsSecondaryScreen::mouseWheel(SInt32 delta) { + // choose button depending on rotation direction + const unsigned int button = (delta >= 0) ? 4 : 5; + + // now use absolute value of delta + if (delta < 0) { + delta = -delta; + } + + // send as many clicks as necessary CDisplayLock display(this); - // FIXME + for (; delta >= 120; delta -= 120) { + XTestFakeButtonEvent(display, button, True, CurrentTime); + XTestFakeButtonEvent(display, button, False, CurrentTime); + } + XSync(display, False); } void CXWindowsSecondaryScreen::setClipboard( diff --git a/server/CXWindowsPrimaryScreen.cpp b/server/CXWindowsPrimaryScreen.cpp index bae8ca5c..ebaabeba 100644 --- a/server/CXWindowsPrimaryScreen.cpp +++ b/server/CXWindowsPrimaryScreen.cpp @@ -124,6 +124,14 @@ void CXWindowsPrimaryScreen::run() if (button != kButtonNone) { m_server->onMouseUp(button); } + else if (xevent.xbutton.button == 4) { + // wheel forward (away from user) + m_server->onMouseWheel(120); + } + else if (xevent.xbutton.button == 5) { + // wheel backward (toward user) + m_server->onMouseWheel(-120); + } break; }