From d62899d4163a6d12bd2abb3f615236d1906d2b2e Mon Sep 17 00:00:00 2001 From: Adam Halim Date: Tue, 24 Sep 2024 16:38:35 +0200 Subject: [PATCH] Use bit shifts when tracking mouse button state I think it makes more sense to use bit shifts instead of decimals for each button. --- vncviewer/Viewport.cxx | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx index 21045dc13b..71ecf98e47 100644 --- a/vncviewer/Viewport.cxx +++ b/vncviewer/Viewport.cxx @@ -614,37 +614,37 @@ int Viewport::handle(int event) // resolved in FLTK. mouseButtonMask &= ~(0x07); if (Fl::event_button1()) - mouseButtonMask |= 1; + mouseButtonMask |= 1 << 0; if (Fl::event_button2()) - mouseButtonMask |= 2; + mouseButtonMask |= 1 << 1; if (Fl::event_button3()) - mouseButtonMask |= 4; + mouseButtonMask |= 1 << 2; switch (event) { case FL_PUSH: if (Fl::event_button() == 8) - mouseButtonMask |= 128; + mouseButtonMask |= 1 << 7; else if (Fl::event_button() == 9) - mouseButtonMask |= 256; + mouseButtonMask |= 1 << 8; break; case FL_RELEASE: if (Fl::event_button() == 8) - mouseButtonMask &= ~(128); + mouseButtonMask &= ~(1 << 7); else if (Fl::event_button() == 9) - mouseButtonMask &= ~(256); + mouseButtonMask &= ~(1 << 8); break; } 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