Don't act on ButtonReleases when we didn't see the corresponding ButtonPress
authorDana Jansens <danakj@orodu.net>
Sat, 1 Mar 2008 01:54:34 +0000 (20:54 -0500)
committerDana Jansens <danakj@orodu.net>
Wed, 19 May 2010 18:13:32 +0000 (14:13 -0400)
Xorg likes to generate ButtonRelease for all buttons when I switch from X to another VT.

src/command.C
src/rxvt.h

index 5386e43..52924d4 100644 (file)
@@ -1857,6 +1857,8 @@ rxvt_term::button_press (XButtonEvent &ev)
 {
   int reportmode = 0, clickintime;
 
+  button_state[ev.button - Button1] = true;
+
   bypass_keystate = ev.state & (ModMetaMask | ShiftMask);
 
   if (!bypass_keystate)
@@ -2103,6 +2105,11 @@ rxvt_term::button_release (XButtonEvent &ev)
 {
   int reportmode = 0;
 
+  if (button_state[ev.button - Button1] == false)
+      return; /* it wasn't pressed so why is it released? */
+
+  button_state[ev.button - Button1] = false;
+
   csrO = 0;            /* reset csr Offset */
   if (!bypass_keystate)
     reportmode = !! (priv_modes & PrivMode_mouse_report);
index c05c9fe..77a6154 100644 (file)
@@ -1061,6 +1061,7 @@ struct rxvt_term : zero_initialized, rxvt_vars, rxvt_screen
                   old_height; /* last used height in screen resize         */
   unsigned long   priv_modes,
                   SavedModes;
+  bool            button_state[5];
 /* ---------- */
   Atom            *xa;
 /* ---------- */