dwm-meillo

diff client.c @ 29:8ad86d0a6a53

added gravity stuff
author Anselm R. Garbe <garbeam@wmii.de>
date Wed, 12 Jul 2006 17:17:15 +0200
parents 3dceb132082d
children 2e0fb4130bfb
line diff
     1.1 --- a/client.c	Wed Jul 12 16:40:37 2006 +0200
     1.2 +++ b/client.c	Wed Jul 12 17:17:15 2006 +0200
     1.3 @@ -18,9 +18,10 @@
     1.4  		return;
     1.5  	stack->x = sx;
     1.6  	stack->y = bh;
     1.7 -	stack->w = sw - 2;
     1.8 -	stack->h = sh - bh - 2;
     1.9 +	stack->w = sw - 2 * stack->border;
    1.10 +	stack->h = sh - bh - 2 * stack->border;
    1.11  	resize(stack);
    1.12 +	discard_events(EnterWindowMask);
    1.13  }
    1.14  
    1.15  void
    1.16 @@ -43,8 +44,8 @@
    1.17  	else
    1.18  		cols = rows;
    1.19  
    1.20 -	gw = (sw - 1)  / cols;
    1.21 -	gh = (sh - bh - 1) / rows;
    1.22 +	gw = (sw - 2 * c->border)  / cols;
    1.23 +	gh = (sh - bh - 2 * c->border) / rows;
    1.24  
    1.25  	for(i = j = 0, c = clients; c; c = c->next) {
    1.26  		c->x = i * gw;
    1.27 @@ -57,6 +58,7 @@
    1.28  			i = 0;
    1.29  		}
    1.30  	}
    1.31 +	discard_events(EnterWindowMask);
    1.32  }
    1.33  
    1.34  void
    1.35 @@ -161,6 +163,10 @@
    1.36  	}
    1.37  	else
    1.38  		c->minw = c->minh = 0;
    1.39 +	if(c->flags & PWinGravity)
    1.40 +		c->grav = size.win_gravity;
    1.41 +	else
    1.42 +		c->grav = NorthWestGravity;
    1.43  }
    1.44  
    1.45  void
    1.46 @@ -213,6 +219,7 @@
    1.47  	c->tw = c->w = wa->width;
    1.48  	c->h = wa->height;
    1.49  	c->th = bh;
    1.50 +	c->border = 1;
    1.51  	update_size(c);
    1.52  	XSetWindowBorderWidth(dpy, c->win, 1);
    1.53  	XSetWindowBorder(dpy, c->win, brush.border);
    1.54 @@ -247,6 +254,61 @@
    1.55  }
    1.56  
    1.57  void
    1.58 +gravitate(Client *c, Bool invert)
    1.59 +{
    1.60 +	int dx = 0, dy = 0;
    1.61 +
    1.62 +	switch(c->grav) {
    1.63 +	case StaticGravity:
    1.64 +	case NorthWestGravity:
    1.65 +	case NorthGravity:
    1.66 +	case NorthEastGravity:
    1.67 +		dy = c->border;
    1.68 +		break;
    1.69 +	case EastGravity:
    1.70 +	case CenterGravity:
    1.71 +	case WestGravity:
    1.72 +		dy = -(c->h / 2) + c->border;
    1.73 +		break;
    1.74 +	case SouthEastGravity:
    1.75 +	case SouthGravity:
    1.76 +	case SouthWestGravity:
    1.77 +		dy = -c->h;
    1.78 +		break;
    1.79 +	default:
    1.80 +		break;
    1.81 +	}
    1.82 +
    1.83 +	switch (c->grav) {
    1.84 +	case StaticGravity:
    1.85 +	case NorthWestGravity:
    1.86 +	case WestGravity:
    1.87 +	case SouthWestGravity:
    1.88 +		dx = c->border;
    1.89 +		break;
    1.90 +	case NorthGravity:
    1.91 +	case CenterGravity:
    1.92 +	case SouthGravity:
    1.93 +		dx = -(c->w / 2) + c->border;
    1.94 +		break;
    1.95 +	case NorthEastGravity:
    1.96 +	case EastGravity:
    1.97 +	case SouthEastGravity:
    1.98 +		dx = -(c->w + c->border);
    1.99 +		break;
   1.100 +	default:
   1.101 +		break;
   1.102 +	}
   1.103 +
   1.104 +	if(invert) {
   1.105 +		dx = -dx;
   1.106 +		dy = -dy;
   1.107 +	}
   1.108 +	c->x += dx;
   1.109 +	c->y += dy;
   1.110 +}
   1.111 +
   1.112 +void
   1.113  resize(Client *c)
   1.114  {
   1.115  	XConfigureEvent e;
   1.116 @@ -260,7 +322,7 @@
   1.117  	e.y = c->y;
   1.118  	e.width = c->w;
   1.119  	e.height = c->h;
   1.120 -	e.border_width = 0;
   1.121 +	e.border_width = c->border;
   1.122  	e.above = None;
   1.123  	e.override_redirect = False;
   1.124  	XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&e);