dwm/screen.c

101 lines
1.5 KiB
C
Raw Normal View History

2006-07-14 15:33:38 -05:00
/*
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
* See LICENSE file for license details.
*/
#include "dwm.h"
void (*arrange)(Arg *) = tiling;
void
view(Arg *arg)
{
Client *c;
tsel = arg->i;
arrange(NULL);
2006-07-14 15:54:09 -05:00
for(c = clients; c; c = getnext(c->next))
drawtitle(c);
drawstatus();
2006-07-14 15:33:38 -05:00
}
void
floating(Arg *arg)
{
Client *c;
arrange = floating;
for(c = clients; c; c = c->next) {
if(c->tags[tsel])
resize(c, True);
else
2006-07-14 15:54:09 -05:00
ban(c);
2006-07-14 15:33:38 -05:00
}
if(sel && !sel->tags[tsel]) {
2006-07-14 15:54:09 -05:00
if((sel = getnext(clients))) {
higher(sel);
2006-07-14 15:33:38 -05:00
focus(sel);
}
}
2006-07-14 15:54:09 -05:00
drawstatus();
2006-07-14 15:33:38 -05:00
}
void
tiling(Arg *arg)
{
Client *c;
int n, i, w, h;
w = sw - mw;
arrange = tiling;
for(n = 0, c = clients; c; c = c->next)
if(c->tags[tsel] && !c->floating)
n++;
if(n > 1)
h = (sh - bh) / (n - 1);
else
h = sh - bh;
for(i = 0, c = clients; c; c = c->next) {
if(c->tags[tsel]) {
if(c->floating) {
2006-07-14 15:54:09 -05:00
higher(c);
2006-07-14 15:33:38 -05:00
resize(c, True);
continue;
}
if(n == 1) {
c->x = sx;
c->y = sy + bh;
c->w = sw - 2 * c->border;
c->h = sh - 2 * c->border - bh;
}
else if(i == 0) {
c->x = sx;
c->y = sy + bh;
c->w = mw - 2 * c->border;
c->h = sh - 2 * c->border - bh;
}
else {
c->x = sx + mw;
c->y = sy + (i - 1) * h + bh;
c->w = w - 2 * c->border;
c->h = h - 2 * c->border;
}
resize(c, False);
i++;
}
else
2006-07-14 15:54:09 -05:00
ban(c);
2006-07-14 15:33:38 -05:00
}
if(!sel || (sel && !sel->tags[tsel])) {
2006-07-14 15:54:09 -05:00
if((sel = getnext(clients))) {
higher(sel);
2006-07-14 15:33:38 -05:00
focus(sel);
}
}
2006-07-14 15:54:09 -05:00
drawstatus();
2006-07-14 15:33:38 -05:00
}