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/Fl_win32.cxx | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'src/Fl_win32.cxx') diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx index 36e77a99b..dec95241e 100644 --- a/src/Fl_win32.cxx +++ b/src/Fl_win32.cxx @@ -1044,9 +1044,12 @@ static int mouse_event(Fl_Window *window, int what, int button, if (wParam & MK_SHIFT) state |= FL_SHIFT; if (wParam & MK_CONTROL) state |= FL_CTRL; #endif - if (wParam & MK_LBUTTON) state |= FL_BUTTON1; - if (wParam & MK_MBUTTON) state |= FL_BUTTON2; - if (wParam & MK_RBUTTON) state |= FL_BUTTON3; + if (wParam & MK_LBUTTON) state |= FL_BUTTON1; // left + if (wParam & MK_MBUTTON) state |= FL_BUTTON2; // right + if (wParam & MK_RBUTTON) state |= FL_BUTTON3; // middle + if (wParam & MK_XBUTTON1) state |= FL_BUTTON4; // side button 1 (back) + if (wParam & MK_XBUTTON2) state |= FL_BUTTON5; // side button 2 (forward) + Fl::e_state = state; switch (what) { @@ -1348,6 +1351,21 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar case WM_RBUTTONUP: mouse_event(window, 2, 3, wParam, lParam); return 0; + case WM_XBUTTONDOWN: { + int xbutton = GET_XBUTTON_WPARAM(wParam) == XBUTTON1 ? 4 : 5; + mouse_event(window, 0, xbutton, wParam, lParam); + return 0; + } + case WM_XBUTTONDBLCLK: { + int xbutton = GET_XBUTTON_WPARAM(wParam) == XBUTTON1 ? 4 : 5; + mouse_event(window, 1, xbutton, wParam, lParam); + return 0; + } + case WM_XBUTTONUP: { + int xbutton = GET_XBUTTON_WPARAM(wParam) == XBUTTON1 ? 4 : 5; + mouse_event(window, 2, xbutton, wParam, lParam); + return 0; + } case WM_MOUSEMOVE: #ifdef USE_TRACK_MOUSE -- cgit v1.2.3