dwm-meillo

diff client.c @ 13:5cc5e55a132d

added protocol killing stuff
author Anselm R. Garbe <garbeam@wmii.de>
date Tue, 11 Jul 2006 16:14:22 +0200
parents 703255003abb
children 5c078b66347b
line diff
     1.1 --- a/client.c	Tue Jul 11 14:53:22 2006 +0200
     1.2 +++ b/client.c	Tue Jul 11 16:14:22 2006 +0200
     1.3 @@ -10,8 +10,8 @@
     1.4  #include "util.h"
     1.5  #include "wm.h"
     1.6  
     1.7 -static void
     1.8 -update_client_name(Client *c)
     1.9 +void
    1.10 +update_name(Client *c)
    1.11  {
    1.12  	XTextProperty name;
    1.13  	int n;
    1.14 @@ -38,6 +38,20 @@
    1.15  }
    1.16  
    1.17  void
    1.18 +focus(Client *c)
    1.19 +{
    1.20 +	Client **l;
    1.21 +	for(l=&stack; *l && *l != c; l=&(*l)->snext);
    1.22 +	eassert(*l == c);
    1.23 +	*l = c->snext;
    1.24 +	c->snext = stack;
    1.25 +	stack = c;
    1.26 +	XRaiseWindow(dpy, c->win);
    1.27 +	XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
    1.28 +	XFlush(dpy);
    1.29 +}
    1.30 +
    1.31 +void
    1.32  manage(Window w, XWindowAttributes *wa)
    1.33  {
    1.34  	Client *c, **l;
    1.35 @@ -59,7 +73,7 @@
    1.36  		(c->size.flags & PMinSize && c->size.flags & PMaxSize
    1.37  		 && c->size.min_width == c->size.max_width
    1.38  		 && c->size.min_height == c->size.max_height);
    1.39 -	update_client_name(c);
    1.40 +	update_name(c);
    1.41  	twa.override_redirect = 1;
    1.42  	twa.background_pixmap = ParentRelative;
    1.43  	twa.event_mask = ExposureMask;
    1.44 @@ -73,9 +87,10 @@
    1.45  	for(l=&clients; *l; l=&(*l)->next);
    1.46  	c->next = *l; /* *l == nil */
    1.47  	*l = c;
    1.48 -	XMapRaised(dpy, c->win);
    1.49 -	XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
    1.50 -	XFlush(dpy);
    1.51 +	c->snext = stack;
    1.52 +	stack = c;
    1.53 +	XMapWindow(dpy, c->win);
    1.54 +	focus(c);
    1.55  }
    1.56  
    1.57  static int
    1.58 @@ -98,12 +113,15 @@
    1.59  	for(l=&clients; *l && *l != c; l=&(*l)->next);
    1.60  	eassert(*l == c);
    1.61  	*l = c->next;
    1.62 +	for(l=&stack; *l && *l != c; l=&(*l)->snext);
    1.63 +	eassert(*l == c);
    1.64 +	*l = c->snext;
    1.65  	free(c);
    1.66  
    1.67  	XFlush(dpy);
    1.68  	XSetErrorHandler(error_handler);
    1.69  	XUngrabServer(dpy);
    1.70 -	/*flush_masked_events(EnterWindowMask); ? */
    1.71 +	flush_events(EnterWindowMask);
    1.72  }
    1.73  
    1.74  
    1.75 @@ -116,3 +134,4 @@
    1.76  			return c;
    1.77  	return NULL;
    1.78  }
    1.79 +