aewl

diff client.c @ 34:cd30cce52b78

added logo+description
author Anselm R. Garbe <garbeam@wmii.de>
date Thu, 13 Jul 2006 09:32:22 +0200
parents e90449e03167
children 989178822938
line diff
     1.1 --- a/client.c	Thu Jul 13 01:55:54 2006 +0200
     1.2 +++ b/client.c	Thu Jul 13 09:32:22 2006 +0200
     1.3 @@ -11,7 +11,9 @@
     1.4  
     1.5  #include "wm.h"
     1.6  
     1.7 -void (*arrange)(void *aux);
     1.8 +static void floating(void);
     1.9 +static void tiling(void);
    1.10 +static void (*arrange)(void) = tiling;
    1.11  
    1.12  void
    1.13  max(void *aux)
    1.14 @@ -26,25 +28,23 @@
    1.15  	discard_events(EnterWindowMask);
    1.16  }
    1.17  
    1.18 -void
    1.19 -floating(void *aux)
    1.20 +static void
    1.21 +floating(void)
    1.22  {
    1.23  	Client *c;
    1.24  
    1.25 -	arrange = floating;
    1.26  	for(c = stack; c; c = c->snext)
    1.27  		resize(c);
    1.28  	discard_events(EnterWindowMask);
    1.29  }
    1.30  
    1.31 -void
    1.32 -grid(void *aux)
    1.33 +static void
    1.34 +tiling(void)
    1.35  {
    1.36  	Client *c;
    1.37  	int n, cols, rows, gw, gh, i, j;
    1.38      float rt, fd;
    1.39  
    1.40 -	arrange = grid;
    1.41  	if(!clients)
    1.42  		return;
    1.43  	for(n = 0, c = clients; c; c = c->next, n++);
    1.44 @@ -76,6 +76,17 @@
    1.45  }
    1.46  
    1.47  void
    1.48 +toggle(void *aux)
    1.49 +{
    1.50 +	if(arrange == floating)
    1.51 +		arrange = tiling;
    1.52 +	else
    1.53 +		arrange = floating;
    1.54 +	arrange();
    1.55 +}
    1.56 +
    1.57 +
    1.58 +void
    1.59  sel(void *aux)
    1.60  {
    1.61  	const char *arg = aux;
    1.62 @@ -114,8 +125,8 @@
    1.63  	c->tw = 0;
    1.64  	for(i = 0; i < TLast; i++)
    1.65  		if(c->tags[i])
    1.66 -			c->tw += textw(&brush.font, c->tags[i]) + brush.font.height;
    1.67 -	c->tw += textw(&brush.font, c->name) + brush.font.height;
    1.68 +			c->tw += textw(&dc.font, c->tags[i]) + dc.font.height;
    1.69 +	c->tw += textw(&dc.font, c->name) + dc.font.height;
    1.70  	if(c->tw > c->w)
    1.71  		c->tw = c->w + 2;
    1.72  	c->tx = c->x + c->w - c->tw + 2;
    1.73 @@ -240,7 +251,7 @@
    1.74  	c->border = 1;
    1.75  	update_size(c);
    1.76  	XSetWindowBorderWidth(dpy, c->win, 1);
    1.77 -	XSetWindowBorder(dpy, c->win, brush.border);
    1.78 +	XSetWindowBorder(dpy, c->win, dc.border);
    1.79  	XSelectInput(dpy, c->win,
    1.80  			StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
    1.81  	XGetTransientForHint(dpy, c->win, &c->trans);
    1.82 @@ -266,7 +277,7 @@
    1.83  			GrabModeAsync, GrabModeSync, None, None);
    1.84  	XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask,
    1.85  			GrabModeAsync, GrabModeSync, None, None);
    1.86 -	arrange(NULL);
    1.87 +	arrange();
    1.88  	focus(c);
    1.89  }
    1.90  
    1.91 @@ -385,7 +396,7 @@
    1.92  	XFlush(dpy);
    1.93  	XSetErrorHandler(error_handler);
    1.94  	XUngrabServer(dpy);
    1.95 -	arrange(NULL);
    1.96 +	arrange();
    1.97  	if(stack)
    1.98  		focus(stack);
    1.99  }
   1.100 @@ -417,21 +428,21 @@
   1.101  	if(c == stack)
   1.102  		return;
   1.103  
   1.104 -	brush.x = brush.y = 0;
   1.105 -	brush.h = c->th;
   1.106 +	dc.x = dc.y = 0;
   1.107 +	dc.h = c->th;
   1.108  
   1.109 -	brush.w = 0;
   1.110 +	dc.w = 0;
   1.111  	for(i = 0; i < TLast; i++) {
   1.112  		if(c->tags[i]) {
   1.113 -			brush.x += brush.w;
   1.114 -			brush.w = textw(&brush.font, c->tags[i]) + brush.font.height;
   1.115 -			draw(&brush, True, c->tags[i]);
   1.116 +			dc.x += dc.w;
   1.117 +			dc.w = textw(&dc.font, c->tags[i]) + dc.font.height;
   1.118 +			draw(True, c->tags[i]);
   1.119  		}
   1.120  	}
   1.121 -	brush.x += brush.w;
   1.122 -	brush.w = textw(&brush.font, c->name) + brush.font.height;
   1.123 -	draw(&brush, True, c->name);
   1.124 -	XCopyArea(dpy, brush.drawable, c->title, brush.gc,
   1.125 +	dc.x += dc.w;
   1.126 +	dc.w = textw(&dc.font, c->name) + dc.font.height;
   1.127 +	draw(True, c->name);
   1.128 +	XCopyArea(dpy, dc.drawable, c->title, dc.gc,
   1.129  			0, 0, c->tw, c->th, 0, 0);
   1.130  	XFlush(dpy);
   1.131  }