From 4f4a9be15b0c52837dd4d4a04ff021cc3e5d691e Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Thu, 26 Sep 2024 17:59:52 +0200 Subject: Support mouse buttons 4 + 5 (aka "side buttons") (#1076, #1068) This work is based on PR 1068 (patch by @CendioHalim) and extended to store button status (4,5) in Fl::event_state() like it's done for other mouse buttons (1-3). Changes: - new symbol: FL_BUTTON4 = side button 1 = "back" - new symbol: FL_BUTTON5 = side button 2 = "forward" - modified : FL_BUTTONS now includes bits for two side buttons Note: the status of these new buttons is not maintained by X11, therefore we need to maintain them in internal variables for this platform. --- src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx index 01fd46536..4a7ace768 100644 --- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx @@ -300,13 +300,21 @@ static void pointer_button(void *data, int b = 0; // 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; } + 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 if (button == BTN_BACK) { Fl::e_state |= FL_BUTTON4; b = 4; } // ? + else if (button == BTN_SIDE) { Fl::e_state |= FL_BUTTON4; b = 4; } // OK: Debian 12 + else if (button == BTN_FORWARD) { Fl::e_state |= FL_BUTTON5; b = 5; } // ? + else if (button == BTN_EXTRA) { Fl::e_state |= FL_BUTTON5; b = 5; } // OK: Debian 12 } 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; } + 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 if (button == BTN_BACK) { Fl::e_state &= ~FL_BUTTON4; b = 4; } // ? + else if (button == BTN_SIDE) { Fl::e_state &= ~FL_BUTTON4; b = 4; } // OK: Debian 12 + else if (button == BTN_FORWARD) { Fl::e_state &= ~FL_BUTTON5; b = 5; } // ? + else if (button == BTN_EXTRA) { Fl::e_state &= ~FL_BUTTON5; b = 5; } // OK: Debian 12 } Fl::e_keysym = FL_Button + b; Fl::e_dx = Fl::e_dy = 0; -- cgit v1.2.3