From 0310b03aefc9243394610f71e174a122902774a1 Mon Sep 17 00:00:00 2001 From: kimci86 Date: Sun, 13 Nov 2022 15:08:00 +0100 Subject: [PATCH] Document that checking XButton1 and XButton2 state on X11 is not supported --- include/SFML/Window/Mouse.hpp | 3 +++ src/SFML/Window/Unix/InputImpl.cpp | 3 +++ src/SFML/Window/Unix/WindowImplX11.cpp | 3 +-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/SFML/Window/Mouse.hpp b/include/SFML/Window/Mouse.hpp index 10cfa5ff7..13d280cbf 100644 --- a/include/SFML/Window/Mouse.hpp +++ b/include/SFML/Window/Mouse.hpp @@ -72,6 +72,9 @@ public: //////////////////////////////////////////////////////////// /// \brief Check if a mouse button is pressed /// + /// \warning Checking the state of buttons Mouse::XButton1 and + /// Mouse::XButton2 is not supported on Linux with X11. + /// /// \param button Button to check /// /// \return True if the button is pressed, false otherwise diff --git a/src/SFML/Window/Unix/InputImpl.cpp b/src/SFML/Window/Unix/InputImpl.cpp index aaf450413..dc0f38203 100644 --- a/src/SFML/Window/Unix/InputImpl.cpp +++ b/src/SFML/Window/Unix/InputImpl.cpp @@ -202,6 +202,9 @@ bool InputImpl::isMouseButtonPressed(Mouse::Button button) // Close the connection with the X server CloseDisplay(display); + // Buttons 4 and 5 are the vertical wheel and 6 and 7 the horizontal wheel. + // There is no mask for buttons 8 and 9, so checking the state of buttons + // Mouse::XButton1 and Mouse::XButton2 is not supported. switch (button) { case Mouse::Left: return buttons & Button1Mask; diff --git a/src/SFML/Window/Unix/WindowImplX11.cpp b/src/SFML/Window/Unix/WindowImplX11.cpp index fb2a6ff77..ef8e93e70 100644 --- a/src/SFML/Window/Unix/WindowImplX11.cpp +++ b/src/SFML/Window/Unix/WindowImplX11.cpp @@ -2020,8 +2020,7 @@ bool WindowImplX11::processEvent(XEvent& windowEvent) // Mouse button pressed case ButtonPress: { - // XXX: Why button 8 and 9? - // Because 4 and 5 are the vertical wheel and 6 and 7 are horizontal wheel ;) + // Buttons 4 and 5 are the vertical wheel and 6 and 7 the horizontal wheel. unsigned int button = windowEvent.xbutton.button; if ((button == Button1) || (button == Button2) ||