diff options
| author | Ivan Kanakarakis <ivan.kanak@gmail.com> | 2011-12-19 01:59:20 +0200 |
|---|---|---|
| committer | Ivan Kanakarakis <ivan.kanak@gmail.com> | 2011-12-19 02:24:01 +0200 |
| commit | d3d1c36787a46da8a000982d83ff7b36b85bb13a (patch) | |
| tree | f28431f14ebf51e8b2cc870be4e63776c347813b | |
| parent | 187368eb0db7751f6ab8af252a40a9d20b270099 (diff) | |
split destroynotify() - introduce wintoclient() function
| -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. */ |
