diff options
Diffstat (limited to 'monsterwm.c')
| -rw-r--r-- | monsterwm.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/monsterwm.c b/monsterwm.c index 58a3959..5644e3f 100644 --- a/monsterwm.c +++ b/monsterwm.c @@ -103,6 +103,7 @@ static void switch_mode(const Arg *arg); static void tile(void); static void togglepanel(); static void update_current(void); +static client* wintoclient(Window w); static int xerrorstart(); #include "config.h" @@ -249,17 +250,10 @@ void deletewindow(Window w) { } void destroynotify(XEvent *e) { - client *c; XDestroyWindowEvent *ev = &e->xdestroywindow; - int cd = current_desktop; - Bool found = False; - - save_desktop(cd); - for(int d=0; d<DESKTOPS && !found; select_desktop(d++)) - for(c=head; c && !found; c=c->next) - if((found = ev->window == c->win)) - removeclient(c); - select_desktop(cd); + client *c; + if((c = wintoclient(ev->window))) + removeclient(c); } void die(const char *errstr, ...) { @@ -661,6 +655,19 @@ void update_current(void) { XSync(dis, False); } +client* wintoclient(Window w) { + client *c = NULL; + Bool found = False; + int cd = current_desktop; + save_desktop(cd); + for(int d=0; d<DESKTOPS && !found; select_desktop(d++)) + for(c=head; c; c=c->next) + if((found = (w == c->win))) + break; + select_desktop(cd); + return c; +} + /* There's no way to check accesses to destroyed windows, thus those cases are * ignored (especially on UnmapNotify's). Other types of errors call Xlibs * default error handler, which may call exit through xerrorlib. */ |
