tabbed

Simple tabbing application for X11.
git clone git://r-36.net/tabbed
Log | Files | Refs | README | LICENSE

commit c6be3a7d9f36725fa968383e979d1ce00488bd8b
parent 22653127836523932e36d19268b134695d13d753
Author: Enno Boland (tox) <tox@s01.de>
Date:   Tue, 15 Dec 2009 09:26:01 +0100

tabbed remembers last viewed tab; open new tabs focused/unfocused can be configured now.
Diffstat:
config.def.h | 2++
tabbed.c | 28+++++++++++++++++++++++-----
2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -6,6 +6,7 @@ static const char *selfgcolor = "#ffffff"; 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 @@ static Key keys[] = { \ { 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 --git a/tabbed.c b/tabbed.c @@ -102,6 +102,7 @@ static void enternotify(const XEvent *e); 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 void (*handler[LASTEvent]) (const XEvent *) = { }; 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 @@ focus(Client *c) { return; } if(!c) + c = sel ? sel : clients; + if(!c) return; resize(c, ww, wh - bh); XRaiseWindow(dpy, c->win); @@ -394,6 +397,10 @@ focus(Client *c) { 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 @@ focusin(const XEvent *e) { focus(sel); } +void +focusonce(const Arg *arg) { + nextfocus = True; +} + Client * getclient(Window w) { Client *c; @@ -591,7 +603,8 @@ manage(Window w) { 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 @@ void 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 @@ setup(void) { 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 @@ unmanage(Client *c) { 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); }