aewl

diff tag.c @ 327:96d09fd98e89

separated several functions into view.c
author Anselm R. Garbe <arg@10kloc.org>
date Tue, 22 Aug 2006 16:50:21 +0200
parents ec8a66a2b9cc
children 2a65e8b3d21a
line diff
     1.1 --- a/tag.c	Tue Aug 22 16:42:29 2006 +0200
     1.2 +++ b/tag.c	Tue Aug 22 16:50:21 2006 +0200
     1.3 @@ -30,97 +30,8 @@
     1.4  static RReg *rreg = NULL;
     1.5  static unsigned int len = 0;
     1.6  
     1.7 -void (*arrange)(Arg *) = DEFMODE;
     1.8 -
     1.9  /* extern */
    1.10  
    1.11 -void
    1.12 -dofloat(Arg *arg)
    1.13 -{
    1.14 -	Client *c;
    1.15 -
    1.16 -	for(c = clients; c; c = c->next) {
    1.17 -		c->ismax = False;
    1.18 -		if(isvisible(c)) {
    1.19 -			resize(c, True, TopLeft);
    1.20 -		}
    1.21 -		else
    1.22 -			ban(c);
    1.23 -	}
    1.24 -	if(!sel || !isvisible(sel))
    1.25 -		sel = getnext(clients);
    1.26 -	if(sel)
    1.27 -		focus(sel);
    1.28 -	else
    1.29 -		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
    1.30 -	restack();
    1.31 -}
    1.32 -
    1.33 -void
    1.34 -dotile(Arg *arg)
    1.35 -{
    1.36 -	int h, i, n, w;
    1.37 -	Client *c;
    1.38 -
    1.39 -	w = sw - mw;
    1.40 -	for(n = 0, c = clients; c; c = c->next)
    1.41 -		if(isvisible(c) && !c->isfloat)
    1.42 -			n++;
    1.43 -
    1.44 -	if(n > 1)
    1.45 -		h = (sh - bh) / (n - 1);
    1.46 -	else
    1.47 -		h = sh - bh;
    1.48 -
    1.49 -	for(i = 0, c = clients; c; c = c->next) {
    1.50 -		c->ismax = False;
    1.51 -		if(isvisible(c)) {
    1.52 -			if(c->isfloat) {
    1.53 -				resize(c, True, TopLeft);
    1.54 -				continue;
    1.55 -			}
    1.56 -			if(n == 1) {
    1.57 -				c->x = sx;
    1.58 -				c->y = sy + bh;
    1.59 -				c->w = sw - 2;
    1.60 -				c->h = sh - 2 - bh;
    1.61 -			}
    1.62 -			else if(i == 0) {
    1.63 -				c->x = sx;
    1.64 -				c->y = sy + bh;
    1.65 -				c->w = mw - 2;
    1.66 -				c->h = sh - 2 - bh;
    1.67 -			}
    1.68 -			else if(h > bh) {
    1.69 -				c->x = sx + mw;
    1.70 -				c->y = sy + (i - 1) * h + bh;
    1.71 -				c->w = w - 2;
    1.72 -				if(i + 1 == n)
    1.73 -					c->h = sh - c->y - 2;
    1.74 -				else
    1.75 -					c->h = h - 2;
    1.76 -			}
    1.77 -			else { /* fallback if h < bh */
    1.78 -				c->x = sx + mw;
    1.79 -				c->y = sy + bh;
    1.80 -				c->w = w - 2;
    1.81 -				c->h = sh - 2 - bh;
    1.82 -			}
    1.83 -			resize(c, False, TopLeft);
    1.84 -			i++;
    1.85 -		}
    1.86 -		else
    1.87 -			ban(c);
    1.88 -	}
    1.89 -	if(!sel || !isvisible(sel))
    1.90 -		sel = getnext(clients);
    1.91 -	if(sel)
    1.92 -		focus(sel);
    1.93 -	else
    1.94 -		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
    1.95 -	restack();
    1.96 -}
    1.97 -
    1.98  Client *
    1.99  getnext(Client *c)
   1.100  {
   1.101 @@ -164,69 +75,6 @@
   1.102  	}
   1.103  }
   1.104  
   1.105 -Bool
   1.106 -isvisible(Client *c)
   1.107 -{
   1.108 -	unsigned int i;
   1.109 -
   1.110 -	for(i = 0; i < ntags; i++)
   1.111 -		if(c->tags[i] && seltag[i])
   1.112 -			return True;
   1.113 -	return False;
   1.114 -}
   1.115 -
   1.116 -void
   1.117 -restack()
   1.118 -{
   1.119 -	static unsigned int nwins = 0;
   1.120 -	static Window *wins = NULL;
   1.121 -	unsigned int f, fi, m, mi, n;
   1.122 -	Client *c;
   1.123 -	XEvent ev;
   1.124 -
   1.125 -	for(f = 0, m = 0, c = clients; c; c = c->next)
   1.126 -		if(isvisible(c)) {
   1.127 -			if(c->isfloat || arrange == dofloat)
   1.128 -				f++;
   1.129 -			else
   1.130 -				m++;
   1.131 -		}
   1.132 -	if(!(n = 2 * (f + m))) {
   1.133 -		drawstatus();
   1.134 -		return;
   1.135 -	}
   1.136 -	if(nwins < n) {
   1.137 -		nwins = n;
   1.138 -		wins = erealloc(wins, nwins * sizeof(Window));
   1.139 -	}
   1.140 -
   1.141 -	fi = 0;
   1.142 -	mi = 2 * f;
   1.143 -	if(sel->isfloat || arrange == dofloat) {
   1.144 -		wins[fi++] = sel->title;
   1.145 -		wins[fi++] = sel->win;
   1.146 -	}
   1.147 -	else {
   1.148 -		wins[mi++] = sel->title;
   1.149 -		wins[mi++] = sel->win;
   1.150 -	}
   1.151 -	for(c = clients; c; c = c->next)
   1.152 -		if(isvisible(c) && c != sel) {
   1.153 -			if(c->isfloat || arrange == dofloat) {
   1.154 -				wins[fi++] = c->title;
   1.155 -				wins[fi++] = c->win;
   1.156 -			}
   1.157 -			else {
   1.158 -				wins[mi++] = c->title;
   1.159 -				wins[mi++] = c->win;
   1.160 -			}
   1.161 -		}
   1.162 -	XRestackWindows(dpy, wins, n);
   1.163 -	drawall();
   1.164 -	XSync(dpy, False);
   1.165 -	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
   1.166 -}
   1.167 -
   1.168  void
   1.169  settags(Client *c)
   1.170  {
   1.171 @@ -277,16 +125,6 @@
   1.172  }
   1.173  
   1.174  void
   1.175 -togglemode(Arg *arg)
   1.176 -{
   1.177 -	arrange = arrange == dofloat ? dotile : dofloat;
   1.178 -	if(sel)
   1.179 -		arrange(NULL);
   1.180 -	else
   1.181 -		drawstatus();
   1.182 -}
   1.183 -
   1.184 -void
   1.185  toggletag(Arg *arg)
   1.186  {
   1.187  	unsigned int i;
   1.188 @@ -302,27 +140,3 @@
   1.189  	if(!isvisible(sel))
   1.190  		arrange(NULL);
   1.191  }
   1.192 -
   1.193 -
   1.194 -void
   1.195 -toggleview(Arg *arg)
   1.196 -{
   1.197 -	unsigned int i;
   1.198 -
   1.199 -	seltag[arg->i] = !seltag[arg->i];
   1.200 -	for(i = 0; i < ntags && !seltag[i]; i++);
   1.201 -	if(i == ntags)
   1.202 -		seltag[arg->i] = True; /* cannot toggle last view */
   1.203 -	arrange(NULL);
   1.204 -}
   1.205 -
   1.206 -void
   1.207 -view(Arg *arg)
   1.208 -{
   1.209 -	unsigned int i;
   1.210 -
   1.211 -	for(i = 0; i < ntags; i++)
   1.212 -		seltag[i] = False;
   1.213 -	seltag[arg->i] = True;
   1.214 -	arrange(NULL);
   1.215 -}