From d3d1c36787a46da8a000982d83ff7b36b85bb13a Mon Sep 17 00:00:00 2001 From: Ivan Kanakarakis Date: Mon, 19 Dec 2011 01:59:20 +0200 Subject: split destroynotify() - introduce wintoclient() function --- monsterwm.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'monsterwm.c') 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; dnext) - 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; dnext) + 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. */ -- cgit v1.3.1