diff options
| author | Enno Boland (tox) <tox@s01.de> | 2009-12-15 09:26:01 +0100 |
|---|---|---|
| committer | Enno Boland (tox) <tox@s01.de> | 2009-12-15 09:26:01 +0100 |
| commit | c6be3a7d9f36725fa968383e979d1ce00488bd8b (patch) | |
| tree | 673ea76ce5a7d543b20c3c54f95440c5caa6e96a /tabbed.c | |
| parent | 22653127836523932e36d19268b134695d13d753 (diff) | |
| download | tabbed-c6be3a7d9f36725fa968383e979d1ce00488bd8b.tar.gz | |
tabbed remembers last viewed tab; open new tabs focused/unfocused can be configured now.
Diffstat (limited to 'tabbed.c')
| -rw-r--r-- | tabbed.c | 28 |
1 files changed, 23 insertions, 5 deletions
@@ -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); } |