summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2023-07-12 18:49:01 +0200
committerAlbrecht Schlosser <albrechts.fltk@online.de>2023-07-12 18:49:01 +0200
commit44840af076569ab6c692d7dcbcc70022d1d40087 (patch)
tree496d3b757d6b2dc6b98ffcbdc9c179a467113609
parent858c3cad869593765fa81f417432d2a0d0e60af5 (diff)
Wayland: keep mouse button state across push/release events
Notes: (1) Fl::e_state holds the current state of all mouse buttons which is returned by Fl::event_buttons() - "plural form". (2) Fl::e_keysym holds the "key" of the current event which can be a mouse button, returned by Fl::event_button() - "singular form".
-rw-r--r--src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
index b4cc6eb58..437cb940f 100644
--- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
+++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
@@ -308,10 +308,16 @@ static void pointer_button(void *data,
return;
}
int b = 0;
- Fl::e_state &= ~FL_BUTTONS;
- if (button == BTN_LEFT) {Fl::e_state |= FL_BUTTON1; b = 1;}
- else if (button == BTN_RIGHT) {Fl::e_state |= FL_BUTTON3; b = 3;}
- else if (button == BTN_MIDDLE) {Fl::e_state |= FL_BUTTON2; b = 2;}
+ // Fl::e_state &= ~FL_BUTTONS; // DO NOT reset the mouse button state!
+ if (state == WL_POINTER_BUTTON_STATE_PRESSED) {
+ if (button == BTN_LEFT) { Fl::e_state |= FL_BUTTON1; b = 1; }
+ else if (button == BTN_RIGHT) { Fl::e_state |= FL_BUTTON3; b = 3; }
+ else if (button == BTN_MIDDLE) { Fl::e_state |= FL_BUTTON2; b = 2; }
+ } else { // must be WL_POINTER_BUTTON_STATE_RELEASED
+ if (button == BTN_LEFT) { Fl::e_state &= ~FL_BUTTON1; b = 1; }
+ else if (button == BTN_RIGHT) { Fl::e_state &= ~FL_BUTTON3; b = 3; }
+ else if (button == BTN_MIDDLE) { Fl::e_state &= ~FL_BUTTON2; b = 2; }
+ }
Fl::e_keysym = FL_Button + b;
Fl::e_dx = Fl::e_dy = 0;