Skip to content

Commit

Permalink
Use bit shifts for mouse buttonMask
Browse files Browse the repository at this point in the history
It makes more sense to use bit shifts instead of decimals for each
button.
  • Loading branch information
CendioHalim committed Oct 7, 2024
1 parent bdaca7f commit 20a083e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions vncviewer/Viewport.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -600,22 +600,22 @@ int Viewport::handle(int event)
case FL_MOUSEWHEEL:
buttonMask = 0;
if (Fl::event_button1())
buttonMask |= 1;
buttonMask |= 1 << 0;
if (Fl::event_button2())
buttonMask |= 2;
buttonMask |= 1 << 1;
if (Fl::event_button3())
buttonMask |= 4;
buttonMask |= 1 << 2;

if (event == FL_MOUSEWHEEL) {
wheelMask = 0;
if (Fl::event_dy() < 0)
wheelMask |= 8;
wheelMask |= 1 << 3;
if (Fl::event_dy() > 0)
wheelMask |= 16;
wheelMask |= 1 << 4;
if (Fl::event_dx() < 0)
wheelMask |= 32;
wheelMask |= 1 << 5;
if (Fl::event_dx() > 0)
wheelMask |= 64;
wheelMask |= 1 << 6;

// A quick press of the wheel "button", followed by a immediate
// release below
Expand Down

0 comments on commit 20a083e

Please sign in to comment.