JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
Fix some bugs in mouse tracking logic
[st.git] / st.c
diff --git a/st.c b/st.c
index 4a91073..3321c31 100644 (file)
--- a/st.c
+++ b/st.c
@@ -823,18 +823,23 @@ mousereport(XEvent *e) {
                button = oldbutton + 32;
                ox = x;
                oy = y;
-       } else if(!IS_SET(MODE_MOUSESGR)
-                       && (e->xbutton.type == ButtonRelease
-                               || button == AnyButton)) {
-               button = 3;
        } else {
-               button -= Button1;
-               if(button >= 3)
-                       button += 64 - 3;
+               if(!IS_SET(MODE_MOUSESGR) && e->xbutton.type == ButtonRelease) {
+                       button = 3;
+               } else {
+                       button -= Button1;
+                       if(button >= 3)
+                               button += 64 - 3;
+               }
                if(e->xbutton.type == ButtonPress) {
                        oldbutton = button;
                        ox = x;
                        oy = y;
+               } else if(e->xbutton.type == ButtonRelease) {
+                       oldbutton = 3;
+                       /* MODE_MOUSEX10: no button release reporting */
+                       if(IS_SET(MODE_MOUSEX10))
+                               return;
                }
        }
 
@@ -851,8 +856,7 @@ mousereport(XEvent *e) {
                                e->xbutton.type == ButtonRelease ? 'm' : 'M');
        } else if(x < 223 && y < 223) {
                len = snprintf(buf, sizeof(buf), "\033[M%c%c%c",
-                               IS_SET(MODE_MOUSEX10)? button-1 : 32+button,
-                               32+x+1, 32+y+1);
+                               32+button, 32+x+1, 32+y+1);
        } else {
                return;
        }