dwm-meillo

diff client.c @ 708:a2d568a5cdb8

applied Sanders all5.patch (thanks for your weekend session, Sander!)
author Anselm R. Garbe <arg@suckless.org>
date Mon, 22 Jan 2007 10:22:58 +0100
parents 399f08187c27
children 6c2fcf88dd9f
line diff
     1.1 --- a/client.c	Fri Jan 19 15:05:07 2007 +0100
     1.2 +++ b/client.c	Mon Jan 22 10:22:58 2007 +0100
     1.3 @@ -79,19 +79,14 @@
     1.4  
     1.5  void
     1.6  focus(Client *c) {
     1.7 -	Client *old;
     1.8 +	Client *old = sel;
     1.9  
    1.10  	if(!issel || (c && !isvisible(c)))
    1.11  		return;
    1.12 -	if(!sel)
    1.13 -		sel = c;
    1.14 -	else if(sel != c) {
    1.15 -		old = sel;
    1.16 -		sel = c;
    1.17 -		if(old) {
    1.18 -			grabbuttons(old, False);
    1.19 -			XSetWindowBorder(dpy, old->win, dc.norm[ColBorder]);
    1.20 -		}
    1.21 +
    1.22 +	if(old && old != c) {
    1.23 +		grabbuttons(old, False);
    1.24 +		XSetWindowBorder(dpy, old->win, dc.norm[ColBorder]);
    1.25  	}
    1.26  	if(c) {
    1.27  		detachstack(c);
    1.28 @@ -103,6 +98,7 @@
    1.29  	}
    1.30  	else
    1.31  		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
    1.32 +	sel = c;
    1.33  	drawstatus();
    1.34  }
    1.35  
    1.36 @@ -134,20 +130,27 @@
    1.37  	c = emallocz(sizeof(Client));
    1.38  	c->tags = emallocz(ntags * sizeof(Bool));
    1.39  	c->win = w;
    1.40 -	c->border = 0;
    1.41  	c->x = wa->x;
    1.42  	c->y = wa->y;
    1.43  	c->w = wa->width;
    1.44  	c->h = wa->height;
    1.45 +	if(c->w == sw && c->h == sh) {
    1.46 +		c->border = 0;
    1.47 +		c->x = sx;
    1.48 +		c->y = sy;
    1.49 +	}
    1.50 +	else {
    1.51 +		c->border = BORDERPX;
    1.52 +		if(c->x < wax)
    1.53 +			c->x = wax;
    1.54 +		if(c->y < way)
    1.55 +			c->y = way;
    1.56 +		if(c->x + c->w + 2 * c->border > wax + waw)
    1.57 +			c->x = wax + waw - c->w - 2 * c->border;
    1.58 +		if(c->y + c->h + 2 * c->border > way + wah)
    1.59 +			c->y = way + wah - c->h - 2 * c->border;
    1.60 +	}
    1.61  	updatesizehints(c);
    1.62 -	if(c->x + c->w + 2 * BORDERPX > sw)
    1.63 -		c->x = sw - c->w - 2 * BORDERPX;
    1.64 -	if(c->x < sx)
    1.65 -		c->x = sx;
    1.66 -	if(c->y + c->h + 2 * BORDERPX > sh)
    1.67 -		c->y = sh - c->h - 2 * BORDERPX;
    1.68 -	if(c->h != sh && c->y < bh)
    1.69 -		c->y = bh;
    1.70  	c->proto = getproto(c->win);
    1.71  	XSelectInput(dpy, c->win,
    1.72  		StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
    1.73 @@ -170,9 +173,7 @@
    1.74  }
    1.75  
    1.76  void
    1.77 -resize(Client *c, Bool sizehints, Corner sticky) {
    1.78 -	int bottom = c->y + c->h;
    1.79 -	int right = c->x + c->w;
    1.80 +resize(Client *c, Bool sizehints) {
    1.81  	XWindowChanges wc;
    1.82  
    1.83  	if(sizehints) {
    1.84 @@ -189,27 +190,24 @@
    1.85  		if(c->maxh && c->h > c->maxh)
    1.86  			c->h = c->maxh;
    1.87  	}
    1.88 -	if(sticky == TopRight || sticky == BotRight)
    1.89 -		c->x = right - c->w;
    1.90 -	if(sticky == BotLeft || sticky == BotRight)
    1.91 -		c->y = bottom - c->h;
    1.92 +	if(c->w == sw && c->h == sh)
    1.93 +		c->border = 0;
    1.94 +	else
    1.95 +		c->border = BORDERPX;
    1.96  	/* offscreen appearance fixes */
    1.97 -	if(c->x + c->w < sx)
    1.98 +	if(c->x + c->w + 2 * c->border < sx)
    1.99  		c->x = sx;
   1.100 -	if(c->y + c->h < bh)
   1.101 -		c->y = bh;
   1.102 +	if(c->y + c->h + 2 * c->border < sy)
   1.103 +		c->y = sy;
   1.104  	if(c->x > sw)
   1.105 -		c->x = sw - c->w;
   1.106 +		c->x = sw - c->w - 2 * c->border;
   1.107  	if(c->y > sh)
   1.108 -		c->y = sh - c->h;
   1.109 +		c->y = sh - c->h - 2 * c->border;
   1.110  	wc.x = c->x;
   1.111  	wc.y = c->y;
   1.112  	wc.width = c->w;
   1.113  	wc.height = c->h;
   1.114 -	if(c->w == sw && c->h == sh)
   1.115 -		wc.border_width = 0;
   1.116 -	else
   1.117 -		wc.border_width = BORDERPX;
   1.118 +	wc.border_width = c->border;
   1.119  	XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc);
   1.120  	configure(c);
   1.121  	XSync(dpy, False);