If not all tabs are shown, trying to select a tab with a mouse checked
against coordinates of tabs when they were last drawn. This lead to
incorrectly choosing tabs not even on screen. Checking only drawn ones
should help.
You can reproduce the bug by running old version of tabbed, opening 8 tabs,
switching to 1st, switching to 8th, and clicking on 3rd tab name – 1st
tab gets focused. With new code, this behaviour is gone.
---
 tabbed.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tabbed.c b/tabbed.c
index 6c8a986..5b1fb9a 100644
--- a/tabbed.c
+++ b/tabbed.c
@@ -170,15 +170,18 @@ void
 buttonpress(const XEvent *e) {
        const XButtonPressedEvent *ev = &e->xbutton;
        int i;
+       int fc;
        Arg arg;
 
-       if((getfirsttab() != 0 && ev->x < TEXTW(before)) || ev->x < 0)
+       fc = getfirsttab();
+
+       if((fc > 0 && ev->x < TEXTW(before)) || ev->x < 0)
                return;
 
        if(ev->y < 0 || ev-> y > bh)
                return;
 
-       for(i = 0; i < nclients; i++) {
+       for(i = (fc > 0) ? fc : 0; i < nclients; i++) {
                if(clients[i]->tabx > ev->x) {
                        switch(ev->button) {
                        case Button1:
-- 
1.8.4.rc2


Reply via email to