diff options
author | arg@10ksloc.org <unknown> | 2006-07-20 16:54:20 +0200 |
---|---|---|
committer | arg@10ksloc.org <unknown> | 2006-07-20 16:54:20 +0200 |
commit | 72707c2fae68f5eba6ea97cbf356bfb968c8a15d (patch) | |
tree | 86285130145cd1672f32c9ebe207b9d41bd10032 /client.c | |
parent | 06dc514bc7327f1a2a35cb533bcf18715305da44 (diff) | |
download | dwm-72707c2fae68f5eba6ea97cbf356bfb968c8a15d.tar.gz |
using double-linked list in order to get correct prev focus handling
Diffstat (limited to 'client.c')
-rw-r--r-- | client.c | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/client.c b/client.c index 1bdebd2..34c69aa 100644 --- a/client.c +++ b/client.c @@ -77,7 +77,6 @@ focusnext(Arg *arg) c = getnext(clients, tsel); if(c) { higher(c); - c->revert = sel; focus(c); } } @@ -93,7 +92,11 @@ focusprev(Arg *arg) if(sel->ismax) togglemax(NULL); - if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) { + if(!(c = getprev(sel->prev))) { + for(c = clients; c && c->next; c = c->next); + c = getprev(c); + } + if(c) { higher(c); focus(c); } @@ -127,6 +130,8 @@ gravitate(Client *c, Bool invert) int dx = 0, dy = 0; switch(c->grav) { + default: + break; case StaticGravity: case NorthWestGravity: case NorthGravity: @@ -143,11 +148,11 @@ gravitate(Client *c, Bool invert) case SouthWestGravity: dy = -(c->h); break; - default: - break; } switch (c->grav) { + default: + break; case StaticGravity: case NorthWestGravity: case WestGravity: @@ -164,8 +169,6 @@ gravitate(Client *c, Bool invert) case SouthEastGravity: dx = -(c->w + c->border); break; - default: - break; } if(invert) { @@ -204,7 +207,6 @@ lower(Client *c) void manage(Window w, XWindowAttributes *wa) { - int diff; Client *c; Window trans; XSetWindowAttributes twa; @@ -224,7 +226,7 @@ manage(Window w, XWindowAttributes *wa) c->proto = getproto(c->win); setsize(c); XSelectInput(dpy, c->win, - StructureNotifyMask | PropertyChangeMask | EnterWindowMask); + StructureNotifyMask | PropertyChangeMask | EnterWindowMask); XGetTransientForHint(dpy, c->win, &trans); twa.override_redirect = 1; twa.background_pixmap = ParentRelative; @@ -237,6 +239,8 @@ manage(Window w, XWindowAttributes *wa) settags(c); + if(clients) + clients->prev = c; c->next = clients; clients = c; @@ -264,6 +268,7 @@ manage(Window w, XWindowAttributes *wa) else { XMapRaised(dpy, c->win); XMapRaised(dpy, c->title); + } } @@ -273,9 +278,15 @@ pop(Client *c) Client **l; for(l = &clients; *l && *l != c; l = &(*l)->next); + if(c->prev) + c->prev->next = c->next; + if(c->next) + c->next->prev = c->prev; *l = c->next; - c->next = clients; /* pop */ + if(clients) + clients->prev = c; + c->next = clients; clients = c; arrange(NULL); } @@ -439,13 +450,18 @@ unmanage(Client *c) XDestroyWindow(dpy, c->title); for(l = &clients; *l && *l != c; l = &(*l)->next); + if(c->prev) + c->prev->next = c->next; + if(c->next) + c->next->prev = c->prev; *l = c->next; - for(l = &clients; *l; l = &(*l)->next) - if((*l)->revert == c) - (*l)->revert = NULL; - if(sel == c) - sel = sel->revert ? sel->revert : clients; - + if(sel == c) { + sel = getnext(c->next, tsel); + if(!sel) + sel = getprev(c->prev); + if(!sel) + sel = clients; + } free(c); XSync(dpy, False); |