[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kde-workspace] kwin: Fix check for no button pressed in Client::buttonReleaseEvent()
From:       Casian Andrei <skeletk13 () gmail ! com>
Date:       2013-10-23 10:23:39
Message-ID: E1VYvbH-00020G-7n () scm ! kde ! org
[Download RAW message or body]

Git commit d54d1e2b30699c752bc81fb489f6e7b955c9b7cc by Casian Andrei.
Committed on 20/10/2013 at 20:30.
Pushed by casianandrei into branch 'master'.

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

M  +12   -2    kwin/events.cpp

http://commits.kde.org/kde-workspace/d54d1e2b30699c752bc81fb489f6e7b955c9b7cc

diff --git a/kwin/events.cpp b/kwin/events.cpp
index 33f5350..ac7a15d 100644
--- a/kwin/events.cpp
+++ b/kwin/events.cpp
@@ -1197,7 +1197,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;
@@ -1209,7 +1209,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) {


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic