]> git.mdlowis.com Git - projs/tide.git/commitdiff
updated button tracking code to accurately reflect button state
authorMichael D. Lowis <mike.lowis@gentex.com>
Wed, 24 May 2017 20:24:12 +0000 (16:24 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Wed, 24 May 2017 20:24:12 +0000 (16:24 -0400)
lib/win.c
lib/x11.c

index 0f2ac7b8450431dc549eac54df129922452f224d..f6cfc62e4a3ed81c2dd9d02d8d65cc7b83e43833 100644 (file)
--- a/lib/win.c
+++ b/lib/win.c
@@ -53,8 +53,7 @@ static bool update_focus(void) {
     int ptr_x, ptr_y;
     bool changed = false;
     /* dont change focus if any mouse buttons are pressed */
-    if ((x11_keybtnstate() & 0x1f00) == 0)
-    {
+    if ((x11_keybtnstate() & 0x1f00) == 0) {
         x11_mouse_get(&ptr_x, &ptr_y);
         if (prev_x != ptr_x || prev_y != ptr_y)
             changed = win_setregion(getregion(ptr_x, ptr_y));
index 2c890621744ffa601fad1287faf891fce53838d9..38d3dc1711baa4105bb3fbc5f7eeddd6f25feb21 100644 (file)
--- a/lib/x11.c
+++ b/lib/x11.c
@@ -280,16 +280,17 @@ static void handle_key(XEvent* event) {
 }
 
 static void handle_mouse(XEvent* e) {
-    int x = 0, y = 0;
+    KeyBtnState = e->xbutton.state;
+    int x = e->xbutton.x;
+    int y = e->xbutton.y;
+
     if (e->type == MotionNotify) {
-        KeyBtnState = e->xmotion.state;
-        x      = e->xmotion.x;
-        y      = e->xmotion.y;
         Config->mouse_drag(KeyBtnState, x, y);
     } else {
-        KeyBtnState = e->xbutton.state;
-        x = e->xbutton.x;
-        y = e->xbutton.y;
+        if (e->type == ButtonRelease)
+            KeyBtnState &= ~(1 << (e->xbutton.button + 7));
+        else
+            KeyBtnState |= (1 << (e->xbutton.button + 7));
         Config->mouse_btn(e->xbutton.button, (e->type == ButtonPress), x, y);
     }
 }