[hackers] [tabbed] tabbed remembers last viewed tab; open new tabs focused/unfocused can be configured now. || Enno Boland (tox)

From: <hg_AT_suckless.org>
Date: Tue, 15 Dec 2009 08:25:26 +0000 (UTC)

changeset: 132:363e60546fc0
tag: tip
user: Enno Boland (tox) <tox_AT_s01.de>
date: Tue Dec 15 09:26:01 2009 +0100
files: config.def.h tabbed.c
description:
tabbed remembers last viewed tab; open new tabs focused/unfocused can be configured now.

diff -r 7990d18655b8 -r 363e60546fc0 config.def.h
--- a/config.def.h Mon Nov 09 00:13:04 2009 +0100
+++ b/config.def.h Tue Dec 15 09:26:01 2009 +0100
@@ -6,6 +6,7 @@
 static const char *before = "<";
 static const char *after = ">";
 static const int tabwidth = 200;
+static const Bool foreground = False;
 
 #define MODKEY ControlMask
 static Key keys[] = { \
@@ -13,6 +14,7 @@
         { MODKEY|ShiftMask, XK_Return, spawn, { .v = (char*[]){ "surf", "-e", winid, NULL} } },
         { MODKEY|ShiftMask, XK_l, rotate, { .i = +1 } },
         { MODKEY|ShiftMask, XK_h, rotate, { .i = -1 } },
+ { MODKEY, XK_Tab, rotate, { .i = 0 } },
         { MODKEY, XK_1, move, { .i = 0 } },
         { MODKEY, XK_2, move, { .i = 1 } },
         { MODKEY, XK_3, move, { .i = 2 } },
diff -r 7990d18655b8 -r 363e60546fc0 tabbed.c
--- a/tabbed.c Mon Nov 09 00:13:04 2009 +0100
+++ b/tabbed.c Tue Dec 15 09:26:01 2009 +0100
@@ -102,6 +102,7 @@
 static void expose(const XEvent *e);
 static void focus(Client *c);
 static void focusin(const XEvent *e);
+static void focusonce(const Arg *arg);
 static Client *getclient(Window w);
 static unsigned long getcolor(const char *colstr);
 static Client *getfirsttab();
@@ -145,12 +146,12 @@
 };
 static int bh, wx, wy, ww, wh;
 static unsigned int numlockmask = 0;
-static Bool running = True;
+static Bool running = True, nextfocus;
 static Display *dpy;
 static DC dc;
 static Atom wmatom[WMLast], xembedatom;
 static Window root, win;
-static Client *clients = NULL, *sel = NULL;
+static Client *clients = NULL, *sel = NULL, *lastsel = NULL;
 static int (*xerrorxlib)(Display *, XErrorEvent *);
 static char winid[64];
 /* configuration, allows nested code to access above variables */
@@ -387,6 +388,8 @@
                 return;
         }
         if(!c)
+ c = sel ? sel : clients;
+ if(!c)
                 return;
         resize(c, ww, wh - bh);
         XRaiseWindow(dpy, c->win);
@@ -394,6 +397,10 @@
         sendxembed(c, XEMBED_FOCUS_IN, XEMBED_FOCUS_CURRENT, 0, 0);
         sendxembed(c, XEMBED_WINDOW_ACTIVATE, 0, 0, 0);
         XStoreName(dpy, win, c->name);
+ if(sel != c) {
+ lastsel = sel;
+ puts("set");
+ }
         sel = c;
         drawbar();
 }
@@ -403,6 +410,11 @@
         focus(sel);
 }
 
+void
+focusonce(const Arg *arg) {
+ nextfocus = True;
+}
+
 Client *
 getclient(Window w) {
         Client *c;
@@ -591,7 +603,8 @@
                 e.xclient.data.l[4] = 0;
                 XSendEvent(dpy, root, False, NoEventMask, &e);
                 XSync(dpy, False);
- focus(c);
+ focus(nextfocus ? c : sel);
+ nextfocus = foreground;
         }
 }
 
@@ -649,7 +662,9 @@
 rotate(const Arg *arg) {
         Client *c;
 
- if(arg->i > 0) {
+ if(arg->i == 0)
+ focus(lastsel);
+ else if(arg->i > 0) {
                 if(sel && sel->next)
                         focus(sel->next);
                 else
@@ -731,6 +746,7 @@
         XSetClassHint(dpy, win, &class_hint);
         XSetWMProtocols(dpy, win, &wmatom[WMDelete], 1);
         snprintf(winid, LENGTH(winid), "%u", (int)win);
+ nextfocus = foreground;
         focus(clients);
 }
 
@@ -777,7 +793,9 @@
                 for(pc = clients; pc && pc->next && pc->next != c; pc = pc->next);
                 pc->next = c->next;
         }
- focus(c->next ? c->next : pc);
+ if(c == lastsel)
+ lastsel = pc;
+ focus(lastsel);
         free(c);
         XSync(dpy, False);
 }
Received on Tue Dec 15 2009 - 08:25:26 UTC

This archive was generated by hypermail 2.2.0 : Tue Dec 15 2009 - 08:36:06 UTC