Skip to content

Commit

Permalink
Mac/Win: Fix interpretation of Shift+scroll wheel
Browse files Browse the repository at this point in the history
On macOS and Windows, horizontal scroll wheel events are communicated to
applications as vertical scroll wheel events with the Shift key held
down, but no corresponding Shift key press or release occurs.  Because
some Un*x applications and window managers use Shift + vertical scroll
wheel events, we need to distinguish horizontal scroll wheel events from
vertical scroll wheel events with an actual Shift key press.
CConn.isKeyPressed() to the rescue.

(regression introduced by 5f3218e)

Fixes #437
  • Loading branch information
dcommander committed Jan 13, 2025
1 parent 9c92276 commit 0e4b7ac
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion java/com/turbovnc/vncviewer/CConn.java
Original file line number Diff line number Diff line change
Expand Up @@ -2517,7 +2517,9 @@ public void writeWheelEvent(MouseWheelEvent ev) {
// acts as if the Shift key is held down, but no Shift key press/release
// events are actually fired.)
boolean isHorizontal =
(Utils.isMac() || Utils.isWindows()) && ev.isShiftDown();
(Utils.isMac() || Utils.isWindows()) && ev.isShiftDown() &&
!pressedKeys.containsValue(Keysyms.SHIFT_L) &&
!pressedKeys.containsValue(Keysyms.SHIFT_R);
// X11 uses Buttons 4, 5, 6, and 7 for (respectively) up, down, left, and
// right scroll wheel events.
if (clicks < 0) {
Expand Down

0 comments on commit 0e4b7ac

Please sign in to comment.