ST stopped sending mouse drag events after any ButtonRelease event was
received. For example if you were dragging and then scrolled the mouse,
the dragging events stopped.

Fixed this by locking the dragging button to the first button pressed.
ST will keep sending drag events for that button until that button is
released.
---
 x.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/x.c b/x.c
index bc3ad5a..b53ede6 100644
--- a/x.c
+++ b/x.c
@@ -246,8 +246,6 @@ static char *opt_line  = NULL;
 static char *opt_name  = NULL;
 static char *opt_title = NULL;
 
-static int oldbutton = 3; /* button event on startup: 3 = release */
-
 void
 clipcopy(const Arg *dummy)
 {
@@ -362,6 +360,7 @@ mousereport(XEvent *e)
            button = e->xbutton.button, state = e->xbutton.state;
        char buf[40];
        static int ox, oy;
+       static int dragbutton = -1; /* -1 = off */
 
        /* from urxvt */
        if (e->xbutton.type == MotionNotify) {
@@ -370,10 +369,10 @@ mousereport(XEvent *e)
                if (!IS_SET(MODE_MOUSEMOTION) && !IS_SET(MODE_MOUSEMANY))
                        return;
                /* MOUSE_MOTION: no reporting if no button is pressed */
-               if (IS_SET(MODE_MOUSEMOTION) && oldbutton == 3)
+               if (IS_SET(MODE_MOUSEMOTION) && dragbutton == -1)
                        return;
 
-               button = oldbutton + 32;
+               button = dragbutton + 32;
                ox = x;
                oy = y;
        } else {
@@ -385,11 +384,14 @@ mousereport(XEvent *e)
                                button += 64 - 3;
                }
                if (e->xbutton.type == ButtonPress) {
-                       oldbutton = button;
-                       ox = x;
-                       oy = y;
+                       if (dragbutton == -1) {
+                               dragbutton = button;
+                               ox = x;
+                               oy = y;
+                       }
                } else if (e->xbutton.type == ButtonRelease) {
-                       oldbutton = 3;
+                       if (button == dragbutton)
+                               dragbutton = -1;
                        /* MODE_MOUSEX10: no button release reporting */
                        if (IS_SET(MODE_MOUSEX10))
                                return;
-- 
2.20.1


Reply via email to