From 1c112474c64c77ff2ffd98c88d093eaab84e2a56 Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Sun, 22 Sep 2013 00:07:27 +0200 Subject: [PATCH] Correct handling of mouse scrolling for osx Setup server to scroll 1 line at a time to match osx scrolling speed. --- client/Mac/MRDPView.m | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/client/Mac/MRDPView.m b/client/Mac/MRDPView.m index 6f1ce51f4..b89599246 100644 --- a/client/Mac/MRDPView.m +++ b/client/Mac/MRDPView.m @@ -486,20 +486,23 @@ DWORD mac_client_thread(void* param) NSPoint loc = [event locationInWindow]; int x = (int) loc.x; int y = (int) loc.y; - + y = height - y; flags = PTR_FLAGS_WHEEL; - - if ([event deltaY] < 0) - flags |= PTR_FLAGS_WHEEL_NEGATIVE | 0x0088; - else - flags |= 0x0078; - - x += (int) [event deltaX]; - y += (int) [event deltaY]; - - instance->input->MouseEvent(instance->input, flags, x, y); + + /* 1 event = 120 units */ + int units = [event deltaY] * 120; + + /* send out all accumulated rotations */ + while(units != 0) + { + /* limit to maximum value in WheelRotationMask (9bit signed value) */ + int step = MIN(MAX(-256, units), 255); + + instance->input->MouseEvent(instance->input, flags | ((UINT16)step & WheelRotationMask), x, y); + units -= step; + } } /** *********************************************************************