[hackers] [tabbed] Correcting the lastsel handling in tabbed. It should be more predictable now. || Christoph Lohmann

From: <hg_AT_suckless.org>
Date: Tue, 27 Nov 2012 20:27:51 +0100 (CET)

changeset: 183:56523f87e30c
tag: tip
user: Christoph Lohmann <20h_AT_r-36.net>
date: Tue Nov 27 20:25:56 2012 +0100
files: tabbed.1 tabbed.c
description:
Correcting the lastsel handling in tabbed. It should be more predictable now.


diff -r c72bc3b6376c -r 56523f87e30c tabbed.1
--- a/tabbed.1 Mon Nov 26 14:55:26 2012 +0100
+++ b/tabbed.1 Tue Nov 27 20:25:56 2012 +0100
_AT_@ -65,7 +65,7 @@
 move selected tab one to the right
 .TP
 .B Ctrl\-Tab
-toggle between tabs
+toggle between the selected and last selected tab
 .TP
 .B Ctrl\-q
 close tab
diff -r c72bc3b6376c -r 56523f87e30c tabbed.c
--- a/tabbed.c Mon Nov 26 14:55:26 2012 +0100
+++ b/tabbed.c Tue Nov 27 20:25:56 2012 +0100
_AT_@ -437,8 +437,8 @@
 
         if(sel != c)
                 lastsel = sel;
+ sel = c;
 
- sel = c;
         drawbar();
 }
 
_AT_@ -682,9 +682,6 @@
                 XSync(dpy, False);
                 focus((nextfocus)? 0 : ((sel < 0)? 0 : sel));
                 nextfocus = foreground;
-
- if(lastsel < 0)
- lastsel = 0;
         }
 }
 
_AT_@ -919,45 +916,52 @@
 
 void
 unmanage(int c) {
- int pc;
-
- if(c < 0 || c >= nclients)
+ if(c < 0 || c >= nclients) {
+ drawbar();
                 return;
+ }
 
         if(!nclients) {
                 return;
         } else if(c == 0) {
                 /* First client. */
- pc = 0;
                 nclients--;
                 free(clients[0]);
                 memmove(&clients[0], &clients[1], sizeof(Client *) * nclients);
         } else if(c == nclients - 1) {
                 /* Last client. */
                 nclients--;
- pc = nclients - 1;
                 free(clients[c]);
                 clients = erealloc(clients, sizeof(Client *) * nclients);
         } else {
                 /* Somewhere inbetween. */
- pc = c + 1;
                 free(clients[c]);
                 memmove(&clients[c], &clients[c+1],
                                 sizeof(Client *) * (nclients - (c + 1)));
                 nclients--;
         }
 
- if(c == lastsel)
- lastsel = 0;
- if(c == sel) {
- sel = pc;
- focus(lastsel);
+ if(c == lastsel) {
+ lastsel = -1;
+ } else if(lastsel > c) {
+ lastsel--;
         }
 
- if(nclients == 0) {
- if(fillagain)
- spawn(NULL);
+ if(sel > c && c > 0) {
+ sel--;
+ lastsel = -1;
         }
+ if(c == nclients && nclients > 0)
+ sel = nclients - 1;
+
+ if(lastsel > -1) {
+ focus(lastsel);
+ } else {
+ focus(sel);
+ }
+
+ if(nclients == 0 && fillagain)
+ spawn(NULL);
 
         drawbar();
         XSync(dpy, False);
Received on Tue Nov 27 2012 - 20:27:51 CET

This archive was generated by hypermail 2.3.0 : Tue Nov 27 2012 - 20:36:05 CET