DefaultVisual(dpy, screen),
CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
- if(clients)
- clients->prev = c;
- c->next = clients;
- clients = c;
-
grabbuttons(c, False);
-
if((tc = getclient(trans))) /* inherit tags */
for(i = 0; i < ntags; i++)
c->tags[i] = tc->tags[i];
c->isfloat = trans
|| (c->maxw && c->minw &&
c->maxw == c->minw && c->maxh == c->minh);
+
+ attach(c);
+
settitle(c);
if(isvisible(c))
sel = c;
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
XDestroyWindow(dpy, c->twin);
- if(c->prev)
- c->prev->next = c->next;
- if(c->next)
- c->next->prev = c->prev;
- if(c == clients)
- clients = c->next;
+ detach(c);
if(sel == c) {
if(trans && (tc = getclient(trans)) && isvisible(tc))
sel = tc;
extern void spawn(Arg *arg);
/* view.c */
+extern void attach(Client *c);
+extern void detach(Client *c);
extern void dofloat(Arg *arg);
extern void dotile(Arg *arg);
extern void focusnext(Arg *arg);
void (*arrange)(Arg *) = DEFMODE;
+void
+attach(Client *c)
+{
+ Client *first = getnext(clients);
+
+ if(!first) {
+ if(clients) {
+ for(first = clients; first->next; first = first->next);
+ first->next = c;
+ c->prev = first;
+ }
+ else
+ clients = c;
+ }
+ else if(first == clients) {
+ c->next = clients;
+ clients->prev = c;
+ clients = c;
+ }
+ else {
+ first->prev->next = c;
+ c->prev = first->prev;
+ first->prev = c;
+ c->next = first;
+ }
+}
+
+void
+detach(Client *c)
+{
+ if(c->prev)
+ c->prev->next = c->next;
+ if(c->next)
+ c->next->prev = c->prev;
+ if(c == clients)
+ clients = c->next;
+ c->next = c->prev = NULL;
+}
+
void
dofloat(Arg *arg)
{
void
zoom(Arg *arg)
{
- Client *c;
+ Client *c = sel;
- if(!sel || (arrange != dotile) || sel->isfloat || sel->ismax)
+ if(!c || (arrange != dotile) || c->isfloat || c->ismax)
return;
- if(sel == getnext(clients)) {
- if((c = getnext(sel->next)))
- sel = c;
- else
+ if(c == getnext(clients))
+ if(!(c = getnext(c->next)))
return;
- }
-
- /* pop */
- sel->prev->next = sel->next;
- if(sel->next)
- sel->next->prev = sel->prev;
- sel->prev = NULL;
- clients->prev = sel;
- sel->next = clients;
- clients = sel;
- focus(sel);
+ detach(c);
+ attach(c);
+ focus(c);
arrange(NULL);
}