* See LICENSE file for license details.
*/
#include "dwm.h"
+#include <stdio.h>
+
+/* static */
+
+static Client *
+minclient()
+{
+ Client *c, *min;
+
+ for(min = c = clients; c; c = c->next)
+ if(c->weight < min->weight)
+ min = c;
+ return min;
+}
+
+
+static void
+reorder()
+{
+ Client *c, *newclients, *tail;
+
+ newclients = tail = NULL;
+ while((c = minclient())) {
+ detach(c);
+ if(tail) {
+ c->prev = tail;
+ tail->next = c;
+ tail = c;
+ }
+ else
+ tail = newclients = c;
+ }
+ clients = newclients;
+}
/* extern */
void (*arrange)(Arg *) = DEFMODE;
+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)
{
Client *c;
+ maximized = False;
+
for(c = clients; c; c = c->next) {
- c->ismax = False;
if(isvisible(c)) {
resize(c, True, TopLeft);
}
ban(c);
}
if(!sel || !isvisible(sel))
- sel = getnext(clients);
- if(sel)
- focus(sel);
- else
- XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
+ focus(getnext(clients));
restack();
}
int h, i, n, w;
Client *c;
+ maximized = False;
+
w = sw - mw;
for(n = 0, c = clients; c; c = c->next)
if(isvisible(c) && !c->isfloat)
h = sh - bh;
for(i = 0, c = clients; c; c = c->next) {
- c->ismax = False;
if(isvisible(c)) {
if(c->isfloat) {
resize(c, True, TopLeft);
ban(c);
}
if(!sel || !isvisible(sel))
- sel = getnext(clients);
- if(sel)
- focus(sel);
- else
- XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
+ focus(getnext(clients));
restack();
}
}
}
+void
+growcol(Arg *arg)
+{
+ if(!sel || (arrange != dotile))
+ return;
+ if(sel == getnext(clients)) {
+ if(mw + arg->i > sw - 100)
+ return;
+ mw += arg->i;
+ }
+ else {
+ if(mw - arg->i < 100)
+ return;
+ mw -= arg->i;
+ }
+ arrange(NULL);
+}
+
Bool
isvisible(Client *c)
{
fi = 0;
mi = 2 * f;
- if(sel->isfloat || arrange == dofloat) {
- wins[fi++] = sel->title;
- wins[fi++] = sel->win;
- }
- else {
- wins[mi++] = sel->title;
- wins[mi++] = sel->win;
+ if(sel) {
+ if(sel->isfloat || arrange == dofloat) {
+ wins[fi++] = sel->twin;
+ wins[fi++] = sel->win;
+ }
+ else {
+ wins[mi++] = sel->twin;
+ wins[mi++] = sel->win;
+ }
}
for(c = clients; c; c = c->next)
if(isvisible(c) && c != sel) {
if(c->isfloat || arrange == dofloat) {
- wins[fi++] = c->title;
+ wins[fi++] = c->twin;
wins[fi++] = c->win;
}
else {
- wins[mi++] = c->title;
+ wins[mi++] = c->twin;
wins[mi++] = c->win;
}
}
void
togglemode(Arg *arg)
{
- arrange = arrange == dofloat ? dotile : dofloat;
+ arrange = (arrange == dofloat) ? dotile : dofloat;
if(sel)
arrange(NULL);
else
for(i = 0; i < ntags && !seltag[i]; i++);
if(i == ntags)
seltag[arg->i] = True; /* cannot toggle last view */
+ reorder();
arrange(NULL);
}
for(i = 0; i < ntags; i++)
seltag[i] = False;
seltag[arg->i] = True;
+ reorder();
+ arrange(NULL);
+}
+
+void
+viewall(Arg *arg)
+{
+ unsigned int i;
+
+ for(i = 0; i < ntags; i++)
+ seltag[i] = True;
+ reorder();
arrange(NULL);
}
void
zoom(Arg *arg)
{
- Client *c;
+ Client *c = sel;
- if(!sel || (arrange != dotile) || sel->isfloat || sel->ismax)
+ if(!c || (arrange != dotile) || c->isfloat || maximized)
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);
+ c->next = clients;
+ clients->prev = c;
+ clients = c;
+ focus(c);
arrange(NULL);
}