[dev] [tabbed] [PATCH] Fix a bug with mouse-selecting (particularly nasty when closing tabs).

From: Alexander Sedov <alex0player_AT_gmail.com>
Date: Fri, 13 Sep 2013 18:08:50 +0400

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
_AT_@ -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
Received on Fri Sep 13 2013 - 16:08:50 CEST

This archive was generated by hypermail 2.3.0 : Fri Sep 13 2013 - 16:12:06 CEST