Skip to content

Commit a37f841

Browse files
committed
VNCConn: rate-limit scroll event handling
Fixes overly fast scrolling with touchpads while keeping mouse wheel scrolling almost as-is. re #263
1 parent 39355fb commit a37f841

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/VNCConn.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,7 @@ bool VNCConn::Init(const wxString& host,
12491249
}
12501250

12511251
conn_stopwatch.Start();
1252+
pointer_scroll_stopwatch.Start();
12521253

12531254
return true;
12541255
}
@@ -1338,7 +1339,7 @@ void VNCConn::sendPointerEvent(wxMouseEvent &event)
13381339
if(event.RightIsDown())
13391340
pev.buttonmask |= rfbButton3Mask;
13401341

1341-
if (event.GetWheelRotation() != 0 && event.GetWheelAxis() == wxMOUSE_WHEEL_VERTICAL) {
1342+
if (event.GetWheelRotation() != 0 && event.GetWheelAxis() == wxMOUSE_WHEEL_VERTICAL && pointer_scroll_stopwatch.Time() >= 20) {
13421343

13431344
if(event.GetWheelRotation() > 0) {
13441345
pev.buttonmask |= rfbWheelUpMask;
@@ -1347,6 +1348,9 @@ void VNCConn::sendPointerEvent(wxMouseEvent &event)
13471348
if(event.GetWheelRotation() < 0) {
13481349
pev.buttonmask |= rfbWheelDownMask;
13491350
}
1351+
1352+
// restart the timer
1353+
pointer_scroll_stopwatch.Start();
13501354
}
13511355

13521356
// Queue event

src/VNCConn.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ class VNCConn: public wxEvtHandler, public wxThreadHelper
298298
int buttonmask;
299299
bool entering;
300300
};
301+
wxStopWatch pointer_scroll_stopwatch;
301302
struct keyEvent
302303
{
303304
rfbKeySym keysym;

0 commit comments

Comments
 (0)