wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit cbdb1fb9b884d61adbf26c7c1071858c1c88f7cf
parent 2e6c149e4971514276eb293fd7fdd23b84c0419a
Author: Anselm R. Garbe <garbeam@wmii.de>
Date:   Thu,  9 Mar 2006 20:25:50 +0100

several fixes (esp. new destroy_client handling)


Diffstat:
cmd/wm/client.c | 22++++++++++++++++++----
cmd/wm/event.c | 13+++++++------
cmd/wm/fs.c | 2+-
cmd/wm/tag.c | 4++--
cmd/wm/wm.c | 9++++++---
cmd/wm/wm.h | 5+++--
6 files changed, 37 insertions(+), 18 deletions(-)

diff --git a/cmd/wm/client.c b/cmd/wm/client.c @@ -350,16 +350,26 @@ manage_client(Client *c) } } +static int +dummy_error_handler(Display *dpy, XErrorEvent *error) +{ + return 0; +} + void -destroy_client(Client *c, Bool unmap) +destroy_client(Client *c) { int i; Client *cl; + XGrabServer(dpy); + XSetErrorHandler(dummy_error_handler); + for(i = 0; i < ntag; i++) - detach_fromtag(tag[i], c, unmap); - if(!unmap) - unmap_client(c); + detach_fromtag(tag[i], c); + + unmap_client(c); + if(c->nframe) { c->rect.x = c->frame[c->sel]->rect.x; c->rect.y = c->frame[c->sel]->rect.y; @@ -375,6 +385,10 @@ destroy_client(Client *c, Bool unmap) if((cl = sel_client_of_tag(tag[sel]))) focus_client(cl); + + XSync(dpy, False); + XSetErrorHandler(wmii_error_handler); + XUngrabServer(dpy); } Client * diff --git a/cmd/wm/event.c b/cmd/wm/event.c @@ -179,11 +179,11 @@ handle_configurerequest(XEvent *e) static void handle_destroynotify(XEvent *e) { + Client *c; XDestroyWindowEvent *ev = &e->xdestroywindow; - Client *c = win2client(ev->window); - if(!c) - return; - destroy_client(c, False); + + if((c = win2client(ev->window))) + destroy_client(c); } static void @@ -265,8 +265,9 @@ handle_propertynotify(XEvent *e) static void handle_unmapnotify(XEvent *e) { - XUnmapEvent *ev = &e->xunmap; Client *c; + XUnmapEvent *ev = &e->xunmap; + if((c = win2client(ev->window))) - destroy_client(c, True); + destroy_client(c); } diff --git a/cmd/wm/fs.c b/cmd/wm/fs.c @@ -1328,7 +1328,7 @@ xwrite(IXPConn *c, Fcall *fcall) buf[fcall->count] = 0; if(m->qid.dir_type == FsDclient) { f = tag[i1]->area[i2]->frame[i3]; - cext_strlcat(f->client->tags, buf, sizeof(f->client->tags)); + cext_strlcpy(f->client->tags, buf, sizeof(f->client->tags)); } else cext_strlcpy(client[i1]->tags, buf, sizeof(client[i1]->tags)); diff --git a/cmd/wm/tag.c b/cmd/wm/tag.c @@ -259,13 +259,13 @@ update_tags() } else { if(clientoftag(tag[j], client[i])) - detach_fromtag(tag[j], client[i], False); + detach_fromtag(tag[j], client[i]); } } } void -detach_fromtag(Tag *t, Client *c, Bool unmap) +detach_fromtag(Tag *t, Client *c) { int i; Client *cl; diff --git a/cmd/wm/wm.c b/cmd/wm/wm.c @@ -19,7 +19,6 @@ static int other_wm_running; static int (*x_error_handler) (Display *, XErrorEvent *); - static char version[] = "wmiiwm - " VERSION ", (C)opyright MMIV-MMVI Anselm R. Garbe\n"; static void @@ -180,9 +179,13 @@ init_screen() * Other types of errors call Xlib's default error handler, which * calls exit(). */ -static int -wmii_error_handler(Display * dpy, XErrorEvent * error) +int +wmii_error_handler(Display *dpy, XErrorEvent *error) { + Client *c; + + if((c = win2client(error->resourceid))) + destroy_client(c); if(error->error_code == BadWindow || (error->request_code == X_SetInputFocus && error->error_code == BadMatch) diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h @@ -261,7 +261,7 @@ void unmap_client(Client *c); void map_client(Client *c); void reparent_client(Client *c, Window w, int x, int y); void manage_client(Client *c); -void destroy_client(Client *c, Bool unmap); +void destroy_client(Client *c); Client *sel_client(); void focus_client(Client *c); void resize_client(Client *c, XRectangle *r, XPoint *pt, Bool ignore_xcall); @@ -318,7 +318,7 @@ int tag2index(Tag *t); Bool has_tag(char **tags, char *tag, unsigned int ntags); void update_tags(); Bool clientoftag(Tag *t, Client *c); -void detach_fromtag(Tag *t, Client *c, Bool unmap); +void detach_fromtag(Tag *t, Client *c); void attach_totag(Tag *t, Client *c); Client *sel_client_of_tag(Tag *t); void restack_tag(Tag *t); @@ -328,3 +328,4 @@ void scan_wins(); Client *win2client(Window w); int win_proto(Window w); int win_state(Window w); +int wmii_error_handler(Display *dpy, XErrorEvent *error);