aewl

diff screen.c @ 73:c2ddb9dbbd10

rearranged
author Anselm R. Garbe <garbeam@wmii.de>
date Fri, 14 Jul 2006 22:33:38 +0200
parents
children 5370ef170cc9
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/screen.c	Fri Jul 14 22:33:38 2006 +0200
     1.3 @@ -0,0 +1,100 @@
     1.4 +/*
     1.5 + * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
     1.6 + * See LICENSE file for license details.
     1.7 + */
     1.8 +
     1.9 +#include "dwm.h"
    1.10 +
    1.11 +void (*arrange)(Arg *) = tiling;
    1.12 +
    1.13 +void
    1.14 +view(Arg *arg)
    1.15 +{
    1.16 +	Client *c;
    1.17 +
    1.18 +	tsel = arg->i;
    1.19 +	arrange(NULL);
    1.20 +
    1.21 +	for(c = clients; c; c = next(c->next))
    1.22 +		draw_client(c);
    1.23 +	draw_bar();
    1.24 +}
    1.25 +
    1.26 +void
    1.27 +floating(Arg *arg)
    1.28 +{
    1.29 +	Client *c;
    1.30 +
    1.31 +	arrange = floating;
    1.32 +	for(c = clients; c; c = c->next) {
    1.33 +		if(c->tags[tsel])
    1.34 +			resize(c, True);
    1.35 +		else
    1.36 +			ban_client(c);
    1.37 +	}
    1.38 +	if(sel && !sel->tags[tsel]) {
    1.39 +		if((sel = next(clients))) {
    1.40 +			craise(sel);
    1.41 +			focus(sel);
    1.42 +		}
    1.43 +	}
    1.44 +	draw_bar();
    1.45 +}
    1.46 +
    1.47 +void
    1.48 +tiling(Arg *arg)
    1.49 +{
    1.50 +	Client *c;
    1.51 +	int n, i, w, h;
    1.52 +
    1.53 +	w = sw - mw;
    1.54 +	arrange = tiling;
    1.55 +	for(n = 0, c = clients; c; c = c->next)
    1.56 +		if(c->tags[tsel] && !c->floating)
    1.57 +			n++;
    1.58 +
    1.59 +	if(n > 1)
    1.60 +		h = (sh - bh) / (n - 1);
    1.61 +	else
    1.62 +		h = sh - bh;
    1.63 +
    1.64 +	for(i = 0, c = clients; c; c = c->next) {
    1.65 +		if(c->tags[tsel]) {
    1.66 +			if(c->floating) {
    1.67 +				craise(c);
    1.68 +				resize(c, True);
    1.69 +				continue;
    1.70 +			}
    1.71 +			if(n == 1) {
    1.72 +				c->x = sx;
    1.73 +				c->y = sy + bh;
    1.74 +				c->w = sw - 2 * c->border;
    1.75 +				c->h = sh - 2 * c->border - bh;
    1.76 +			}
    1.77 +			else if(i == 0) {
    1.78 +				c->x = sx;
    1.79 +				c->y = sy + bh;
    1.80 +				c->w = mw - 2 * c->border;
    1.81 +				c->h = sh - 2 * c->border - bh;
    1.82 +			}
    1.83 +			else {
    1.84 +				c->x = sx + mw;
    1.85 +				c->y = sy + (i - 1) * h + bh;
    1.86 +				c->w = w - 2 * c->border;
    1.87 +				c->h = h - 2 * c->border;
    1.88 +			}
    1.89 +			resize(c, False);
    1.90 +			i++;
    1.91 +		}
    1.92 +		else
    1.93 +			ban_client(c);
    1.94 +	}
    1.95 +	if(!sel || (sel && !sel->tags[tsel])) {
    1.96 +		if((sel = next(clients))) {
    1.97 +			craise(sel);
    1.98 +			focus(sel);
    1.99 +		}
   1.100 +	}
   1.101 +	draw_bar();
   1.102 +}
   1.103 +