aewl

changeset 400:052657ff2e7b

applied Sanders max_and_focus.patch
author Anselm R. Garbe <arg@10kloc.org>
date Mon, 04 Sep 2006 08:55:49 +0200
parents 74739798b0b2
children 1eb2eb405653
files client.c dwm.h event.c main.c view.c
diffstat 5 files changed, 49 insertions(+), 45 deletions(-) [+]
line diff
     1.1 --- a/client.c	Fri Sep 01 15:31:59 2006 +0200
     1.2 +++ b/client.c	Mon Sep 04 08:55:49 2006 +0200
     1.3 @@ -82,22 +82,29 @@
     1.4  void
     1.5  focus(Client *c)
     1.6  {
     1.7 -	Client *old = sel;
     1.8 +	Client *old;
     1.9  
    1.10  	if(!issel)
    1.11  		return;
    1.12  	if(!sel)
    1.13  		sel = c;
    1.14  	else if(sel != c) {
    1.15 -		if(sel->ismax)
    1.16 +		if(maximized)
    1.17  			togglemax(NULL);
    1.18 +		old = sel;
    1.19  		sel = c;
    1.20 -		grabbuttons(old, False);
    1.21 -		drawtitle(old);
    1.22 +		if(old) {
    1.23 +			grabbuttons(old, False);
    1.24 +			drawtitle(old);
    1.25 +		}
    1.26  	}
    1.27 -	grabbuttons(c, True);
    1.28 -	drawtitle(c);
    1.29 -	XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
    1.30 +	if(c) {
    1.31 +		grabbuttons(c, True);
    1.32 +		drawtitle(c);
    1.33 +		XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
    1.34 +	}
    1.35 +	else
    1.36 +		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
    1.37  }
    1.38  
    1.39  Client *
    1.40 @@ -247,8 +254,6 @@
    1.41  	clients = c;
    1.42  
    1.43  	settitle(c);
    1.44 -	if(isvisible(c))
    1.45 -		sel = c;
    1.46  	arrange(NULL);
    1.47  	XMapWindow(dpy, c->win);
    1.48  	XMapWindow(dpy, c->twin);
    1.49 @@ -366,12 +371,13 @@
    1.50  togglemax(Arg *arg)
    1.51  {
    1.52  	int ox, oy, ow, oh;
    1.53 +	Client *c;
    1.54  	XEvent ev;
    1.55  
    1.56  	if(!sel)
    1.57  		return;
    1.58  
    1.59 -	if((sel->ismax = !sel->ismax)) {
    1.60 +	if((maximized = !maximized)) {
    1.61  		ox = sel->x;
    1.62  		oy = sel->y;
    1.63  		ow = sel->w;
    1.64 @@ -382,6 +388,9 @@
    1.65  		sel->h = sh - 2 - bh;
    1.66  
    1.67  		restack();
    1.68 +		for(c = getnext(clients); c; c = getnext(c->next))
    1.69 +			if(c != sel)
    1.70 +				ban(c);
    1.71  		resize(sel, arrange == dofloat, TopLeft);
    1.72  
    1.73  		sel->x = ox;
    1.74 @@ -390,37 +399,36 @@
    1.75  		sel->h = oh;
    1.76  	}
    1.77  	else
    1.78 -		resize(sel, False, TopLeft);
    1.79 +		arrange(NULL);
    1.80  	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
    1.81  }
    1.82  
    1.83  void
    1.84  unmanage(Client *c)
    1.85  {
    1.86 -	Client *tc;
    1.87 +	Client *tc, *fc;
    1.88  	Window trans;
    1.89  	XGrabServer(dpy);
    1.90  	XSetErrorHandler(xerrordummy);
    1.91  
    1.92 -	XGetTransientForHint(dpy, c->win, &trans);
    1.93 +	detach(c);
    1.94 +	if(sel == c) {
    1.95 +		XGetTransientForHint(dpy, c->win, &trans);
    1.96 +		if(trans && (tc = getclient(trans)) && isvisible(tc))
    1.97 +			fc = tc;
    1.98 +		else
    1.99 +			fc = getnext(clients);
   1.100 +		focus(fc);
   1.101 +	}
   1.102  
   1.103  	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
   1.104  	XDestroyWindow(dpy, c->twin);
   1.105  
   1.106 -	detach(c);
   1.107 -	if(sel == c) {
   1.108 -		if(trans && (tc = getclient(trans)) && isvisible(tc))
   1.109 -			sel = tc;
   1.110 -		else
   1.111 -			sel = getnext(clients);
   1.112 -	}
   1.113  	free(c->tags);
   1.114  	free(c);
   1.115  
   1.116  	XSync(dpy, False);
   1.117  	XSetErrorHandler(xerror);
   1.118  	XUngrabServer(dpy);
   1.119 -	if(sel)
   1.120 -		focus(sel);
   1.121  	arrange(NULL);
   1.122  }
     2.1 --- a/dwm.h	Fri Sep 01 15:31:59 2006 +0200
     2.2 +++ b/dwm.h	Mon Sep 04 08:55:49 2006 +0200
     2.3 @@ -58,7 +58,6 @@
     2.4  	long flags; 
     2.5  	unsigned int border, weight;
     2.6  	Bool isfloat;
     2.7 -	Bool ismax;
     2.8  	Bool *tags;
     2.9  	Client *next;
    2.10  	Client *prev;
    2.11 @@ -73,7 +72,7 @@
    2.12  extern void (*handler[LASTEvent])(XEvent *);
    2.13  extern void (*arrange)(Arg *);
    2.14  extern Atom wmatom[WMLast], netatom[NetLast];
    2.15 -extern Bool running, issel, *seltag;
    2.16 +extern Bool running, issel, maximized, *seltag;
    2.17  extern Client *clients, *sel;
    2.18  extern Cursor cursor[CurLast];
    2.19  extern DC dc;
     3.1 --- a/event.c	Fri Sep 01 15:31:59 2006 +0200
     3.2 +++ b/event.c	Mon Sep 04 08:55:49 2006 +0200
     3.3 @@ -131,15 +131,15 @@
     3.4  	}
     3.5  	else if((c = getclient(ev->window))) {
     3.6  		focus(c);
     3.7 -		if(c->ismax || CLEANMASK(ev->state) != MODKEY)
     3.8 +		if(maximized || CLEANMASK(ev->state) != MODKEY)
     3.9  			return;
    3.10 -		if((ev->button == Button1) && ((arrange == dofloat) || c->isfloat)) {
    3.11 +		if(ev->button == Button1 && (arrange == dofloat || c->isfloat)) {
    3.12  			restack(c);
    3.13  			movemouse(c);
    3.14  		}
    3.15  		else if(ev->button == Button2)
    3.16  			zoom(NULL);
    3.17 -		else if(ev->button == Button3 && ((arrange == dofloat) || c->isfloat)) {
    3.18 +		else if(ev->button == Button3 && (arrange == dofloat || c->isfloat)) {
    3.19  			restack(c);
    3.20  			resizemouse(c);
    3.21  		}
    3.22 @@ -173,7 +173,7 @@
    3.23  	XWindowChanges wc;
    3.24  
    3.25  	if((c = getclient(ev->window))) {
    3.26 -		if(!c->isfloat && (arrange != dofloat) && c->ismax) {
    3.27 +		if((c == sel) && !c->isfloat && (arrange != dofloat) && maximized) {
    3.28  			synconfig(c, sx, sy + bh, sw - 2, sh - 2 - bh, ev->border_width);
    3.29  			XSync(dpy, False);
    3.30  			return;
     4.1 --- a/main.c	Fri Sep 01 15:31:59 2006 +0200
     4.2 +++ b/main.c	Mon Sep 04 08:55:49 2006 +0200
     4.3 @@ -24,6 +24,7 @@
     4.4  Atom wmatom[WMLast], netatom[NetLast];
     4.5  Bool running = True;
     4.6  Bool issel = True;
     4.7 +Bool maximized = False;
     4.8  Client *clients = NULL;
     4.9  Client *sel = NULL;
    4.10  Cursor cursor[CurLast];
     5.1 --- a/view.c	Fri Sep 01 15:31:59 2006 +0200
     5.2 +++ b/view.c	Mon Sep 04 08:55:49 2006 +0200
     5.3 @@ -57,22 +57,20 @@
     5.4  void
     5.5  dofloat(Arg *arg)
     5.6  {
     5.7 -	Client *c;
     5.8 +	Client *c, *fc;
     5.9 +
    5.10 +	maximized = False;
    5.11  
    5.12  	for(c = clients; c; c = c->next) {
    5.13 -		c->ismax = False;
    5.14  		if(isvisible(c)) {
    5.15  			resize(c, True, TopLeft);
    5.16  		}
    5.17  		else
    5.18  			ban(c);
    5.19  	}
    5.20 -	if(!sel || !isvisible(sel))
    5.21 -		sel = getnext(clients);
    5.22 -	if(sel)
    5.23 -		focus(sel);
    5.24 -	else
    5.25 -		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
    5.26 +	if(!(fc = sel) || !isvisible(fc))
    5.27 +		fc = getnext(clients);
    5.28 +	focus(fc);
    5.29  	restack();
    5.30  }
    5.31  
    5.32 @@ -80,7 +78,9 @@
    5.33  dotile(Arg *arg)
    5.34  {
    5.35  	int h, i, n, w;
    5.36 -	Client *c;
    5.37 +	Client *c, *fc;
    5.38 +
    5.39 +	maximized = False;
    5.40  
    5.41  	w = sw - mw;
    5.42  	for(n = 0, c = clients; c; c = c->next)
    5.43 @@ -93,7 +93,6 @@
    5.44  		h = sh - bh;
    5.45  
    5.46  	for(i = 0, c = clients; c; c = c->next) {
    5.47 -		c->ismax = False;
    5.48  		if(isvisible(c)) {
    5.49  			if(c->isfloat) {
    5.50  				resize(c, True, TopLeft);
    5.51 @@ -132,12 +131,9 @@
    5.52  		else
    5.53  			ban(c);
    5.54  	}
    5.55 -	if(!sel || !isvisible(sel))
    5.56 -		sel = getnext(clients);
    5.57 -	if(sel)
    5.58 -		focus(sel);
    5.59 -	else
    5.60 -		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
    5.61 +	if(!(fc = sel) || !isvisible(fc))
    5.62 +		fc = getnext(clients);
    5.63 +	focus(fc);
    5.64  	restack();
    5.65  }
    5.66  
    5.67 @@ -289,7 +285,7 @@
    5.68  {
    5.69  	Client *c = sel;
    5.70  
    5.71 -	if(!c || (arrange != dotile) || c->isfloat || c->ismax)
    5.72 +	if(!c || (arrange != dotile) || c->isfloat || maximized)
    5.73  		return;
    5.74  
    5.75  	if(c == getnext(clients))