From f70a4130bd8736d17c93a268c58f12d6d0d7dfe4 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Thu, 27 May 2010 13:55:34 -0400 Subject: [PATCH] [witray] Handle badly behavied clients. Closes issue #183. --- cmd/tray/client.c | 10 ++++++++++ cmd/tray/xembed.c | 4 +++- config.mk | 2 +- lib/libstuff/event/mapnotify.c | 2 +- lib/libstuff/event/maprequest.c | 2 +- lib/libstuff/event/reparentnotify.c | 2 +- mk/gcc.mk | 2 +- 7 files changed, 18 insertions(+), 6 deletions(-) diff --git a/cmd/tray/client.c b/cmd/tray/client.c index 29b5a11f..fc597aff 100644 --- a/cmd/tray/client.c +++ b/cmd/tray/client.c @@ -172,19 +172,29 @@ configreq_event(Window *w, void *aux, XConfigureRequestEvent *e) { static void map_event(Window *w, void *aux, XMapEvent *e) { + Dprint("client map_event(%W)\n", w); + w->mapped = true; tray_update(); } static void unmap_event(Window *w, void *aux, XUnmapEvent *e) { + Dprint("client map_event(%W)\n", w); tray_update(); } +static void +reparent_event(Window *w, void *aux, XReparentEvent *e) { + + Dprint("client reparent_event(%W)\n", w); +} + static Handlers handlers = { .config = config_event, .configreq = configreq_event, .map = map_event, .unmap = unmap_event, + .reparent = reparent_event, }; diff --git a/cmd/tray/xembed.c b/cmd/tray/xembed.c index ff72611e..ff3fd234 100644 --- a/cmd/tray/xembed.c +++ b/cmd/tray/xembed.c @@ -56,8 +56,10 @@ void xembed_disown(XEmbed *xembed) { pophandler(xembed->w, &handlers); - if(xembed->flags != DEAD) + if(xembed->flags != DEAD) { reparentwindow(xembed->w, &scr.root, ZP); + unmapwin(xembed->w); + } if(xembed->cleanup) xembed->cleanup(xembed); free(xembed); diff --git a/config.mk b/config.mk index 79dc4f26..71560e4d 100644 --- a/config.mk +++ b/config.mk @@ -17,7 +17,7 @@ TERMINAL = xterm # Flags include $(ROOT)/mk/gcc.mk -CFLAGS += $(DEBUGCFLAGS) -O0 +CFLAGS += -Os $(DEBUGCFLAGS) LDFLAGS += -g # Compiler, Linker. Linker should usually *not* be ld. diff --git a/lib/libstuff/event/mapnotify.c b/lib/libstuff/event/mapnotify.c index 7d9c13c4..d26ae83a 100644 --- a/lib/libstuff/event/mapnotify.c +++ b/lib/libstuff/event/mapnotify.c @@ -7,6 +7,6 @@ void event_mapnotify(XMapEvent *ev) { Window *w; - if((w = findwin(ev->window))) + if((w = findwin(ev->event))) event_handle(w, map, ev); } diff --git a/lib/libstuff/event/maprequest.c b/lib/libstuff/event/maprequest.c index 09b47711..be93d162 100644 --- a/lib/libstuff/event/maprequest.c +++ b/lib/libstuff/event/maprequest.c @@ -7,6 +7,6 @@ void event_maprequest(XMapRequestEvent *ev) { Window *w; - if((w = findwin(ev->parent))) + if((w = findwin(ev->parent))) event_handle(w, mapreq, ev); } diff --git a/lib/libstuff/event/reparentnotify.c b/lib/libstuff/event/reparentnotify.c index 5ca4dd03..358638a6 100644 --- a/lib/libstuff/event/reparentnotify.c +++ b/lib/libstuff/event/reparentnotify.c @@ -7,6 +7,6 @@ void event_reparentnotify(XReparentEvent *ev) { Window *w; - if((w = findwin(ev->window))) + if((w = findwin(ev->event))) event_handle(w, reparent, ev); } diff --git a/mk/gcc.mk b/mk/gcc.mk index b37b59cf..259eff43 100644 --- a/mk/gcc.mk +++ b/mk/gcc.mk @@ -1,6 +1,6 @@ DEBUGCFLAGS = \ -g \ - -O1 \ + -O0 \ -fno-builtin \ -fno-inline \ -fno-omit-frame-pointer \