From b5b7fac056d0f003aeecd8ecb2153f5a72e0ea6b Mon Sep 17 00:00:00 2001 From: Casian Andrei Date: Sun, 20 Oct 2013 23:30:44 +0300 Subject: [PATCH] Fix check for no button pressed in Client::buttonReleaseEvent() There is a check in Client::buttonReleaseEvent() for the state of the mouse buttons compared to the button masks for button 1, 2, 3 (X11 button indices). The check was: if ((state & (Button1Mask & Button2Mask & Button3Mask)) == 0) { ... } <=> if (state & 0 == 0) <=> if (true) This change assumes what the check was supposed to be and fixes the problem. The correct fix was proposed by Thomas. REVIEW: 113359 --- events.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/events.cpp b/events.cpp index 1e8ba5008f..19532b90ff 100644 --- a/events.cpp +++ b/events.cpp @@ -1134,7 +1134,7 @@ void Client::processMousePressEvent(QMouseEvent* e) } // return value matters only when filtering events before decoration gets them -bool Client::buttonReleaseEvent(xcb_window_t w, int /*button*/, int state, int x, int y, int x_root, int y_root) +bool Client::buttonReleaseEvent(xcb_window_t w, int button, int state, int x, int y, int x_root, int y_root) { if (w == decorationId() && !buttonDown) return false; @@ -1146,7 +1146,17 @@ bool Client::buttonReleaseEvent(xcb_window_t w, int /*button*/, int state, int x return true; x = this->x(); // translate from grab window to local coords y = this->y(); - if ((state & (Button1Mask & Button2Mask & Button3Mask)) == 0) { + + // Check whether other buttons are still left pressed + int buttonMask = XCB_BUTTON_MASK_1 | XCB_BUTTON_MASK_2 | XCB_BUTTON_MASK_3; + if (button == XCB_BUTTON_INDEX_1) + buttonMask &= ~XCB_BUTTON_MASK_1; + else if (button == XCB_BUTTON_INDEX_2) + buttonMask &= ~XCB_BUTTON_MASK_2; + else if (button == XCB_BUTTON_INDEX_3) + buttonMask &= ~XCB_BUTTON_MASK_3; + + if ((state & buttonMask) == 0) { buttonDown = false; stopDelayedMoveResize(); if (moveResizeMode) {