From 381763fd75215143252dd551f3d8486986693b60 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Fri, 29 Feb 2008 20:54:34 -0500 Subject: [PATCH] Don't act on ButtonReleases when we didn't see the corresponding ButtonPress Xorg likes to generate ButtonRelease for all buttons when I switch from X to another VT. --- src/command.C | 7 +++++++ src/rxvt.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/command.C b/src/command.C index 5386e43..52924d4 100644 --- a/src/command.C +++ b/src/command.C @@ -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); diff --git a/src/rxvt.h b/src/rxvt.h index c05c9fe..77a6154 100644 --- a/src/rxvt.h +++ b/src/rxvt.h @@ -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; /* ---------- */ -- 1.9.1