///////////////////////////////////////////////////////
| 83 | |
| 84 | //////////////////////////////////////////////////////////// |
| 85 | bool isMouseButtonPressed(Mouse::Button button) |
| 86 | { |
| 87 | // Open a connection with the X server |
| 88 | const auto display = openDisplay(); |
| 89 | |
| 90 | // we don't care about these but they are required |
| 91 | ::Window root = 0; |
| 92 | ::Window child = 0; |
| 93 | int wx = 0; |
| 94 | int wy = 0; |
| 95 | int gx = 0; |
| 96 | int gy = 0; |
| 97 | |
| 98 | unsigned int buttons = 0; |
| 99 | XQueryPointer(display.get(), DefaultRootWindow(display.get()), &root, &child, &gx, &gy, &wx, &wy, &buttons); |
| 100 | |
| 101 | // Buttons 4 and 5 are the vertical wheel and 6 and 7 the horizontal wheel. |
| 102 | // There is no mask for buttons 8 and 9, so checking the state of buttons |
| 103 | // Mouse::Button::Extra1 and Mouse::Button::Extra2 is not supported. |
| 104 | // clang-format off |
| 105 | switch (button) |
| 106 | { |
| 107 | case Mouse::Button::Left: return buttons & Button1Mask; |
| 108 | case Mouse::Button::Right: return buttons & Button3Mask; |
| 109 | case Mouse::Button::Middle: return buttons & Button2Mask; |
| 110 | case Mouse::Button::Extra1: return false; // not supported by X |
| 111 | case Mouse::Button::Extra2: return false; // not supported by X |
| 112 | default: return false; |
| 113 | } |
| 114 | // clang-format on |
| 115 | } |
| 116 | |
| 117 | |
| 118 | //////////////////////////////////////////////////////////// |
nothing calls this directly
no test coverage detected