[gnome-remote-desktop] session-rdp: Interpret the wheel rotation value correctly



commit f134b16b90269d7905f2bb6ea943f9c78c2ea380
Author: Pascal Nowack <Pascal Nowack gmx de>
Date:   Wed Feb 10 12:28:41 2021 +0100

    session-rdp: Interpret the wheel rotation value correctly
    
    Due to a misinterpretation of the wheel rotation value,
    gnome-remote-desktop currently uses the positive wheel value as
    rotation value and negates the value if the negative flag is present.
    This is however not correct and the error was actually inherited from
    xfreerdps and westons behaviour regarding the rotation value.
    Analyzing the communication between gnome-remote-desktop and mstsc
    shows however that the wheel rotation value is only correct when the
    actual wheel value is positive.
    For the opposite direction, mstsc (and other clients too) uses the
    two's complement of the value in 9Bits.
    
    Therefore, interpret the wheel rotation value correctly for the
    negative direction, by applying the two's complement again to retrieve
    the value, i.e. negate the bits in the value and add 1 to the value.

 src/grd-session-rdp.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/src/grd-session-rdp.c b/src/grd-session-rdp.c
index ff70431..ffe3be7 100644
--- a/src/grd-session-rdp.c
+++ b/src/grd-session-rdp.c
@@ -1138,6 +1138,7 @@ rdp_input_mouse_event (rdpInput *rdp_input,
   GrdRdpEventQueue *rdp_event_queue = session_rdp->rdp_event_queue;
   GrdButtonState button_state;
   int32_t button = 0;
+  uint16_t axis_value;
   double axis_step;
 
   if (!is_rdp_peer_flag_set (rdp_peer_context, RDP_PEER_ACTIVATED) ||
@@ -1174,7 +1175,14 @@ rdp_input_mouse_event (rdpInput *rdp_input,
   if (!(flags & PTR_FLAGS_WHEEL) && !(flags & PTR_FLAGS_HWHEEL))
     return TRUE;
 
-  axis_step = -(flags & 0xFF) / 120.0;
+  axis_value = flags & WheelRotationMask;
+  if (axis_value & PTR_FLAGS_WHEEL_NEGATIVE)
+    {
+      axis_value = ~axis_value & WheelRotationMask;
+      ++axis_value;
+    }
+
+  axis_step = -axis_value / 120.0;
   if (flags & PTR_FLAGS_WHEEL_NEGATIVE)
     axis_step = -axis_step;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]