From 6594959ce88075310ca1b5f076c6542b15949848 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Mon, 19 Sep 2011 22:06:50 -0400 Subject: [PATCH] Deal with a particular Qt systray replacement bug. Cleanup a bit more politely on sigterm/sigint. --- cmd/tray/Makefile | 2 +- cmd/tray/client.c | 4 ++-- cmd/tray/main.c | 6 +++--- cmd/tray/selection.c | 4 ++-- cmd/tray/xembed.c | 8 ++++++++ man/witray.man1 | 3 +-- 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/cmd/tray/Makefile b/cmd/tray/Makefile index c60624eb..2789c5d9 100644 --- a/cmd/tray/Makefile +++ b/cmd/tray/Makefile @@ -5,7 +5,7 @@ include $(ROOT)/mk/wmii.mk main.c: $(ROOT)/mk/wmii.mk TARG = witray -HFILES= dat.h fns.h +HFILES= dat.h fns.h selection.h PACKAGES += $(X11PACKAGES) diff --git a/cmd/tray/client.c b/cmd/tray/client.c index d9cc10d8..f588ecfe 100644 --- a/cmd/tray/client.c +++ b/cmd/tray/client.c @@ -27,7 +27,7 @@ client_manage(XWindow w) { XAddToSaveSet(display, w); c->xembed = xembed_swallow(tray.win, &c->w, client_cleanup); if(traperrors(false)) { - fprint(1, "client_manage(0x%ulx): Caught error.\n", w); + fprint(2, "client_manage(0x%ulx): Caught error.\n", w); if(c->xembed) xembed_disown(c->xembed); return; @@ -112,7 +112,7 @@ void client_opcode(Client *c, long message, long l1, long l2, long l3) { Message *m, **mp; - Dprint("client_opcode(%p, %s, %lx, %lx, %lx)\n", + Dprint("client_opcode(%p, %s, %ulx, %ulx, %ulx)\n", c, message == TrayRequestDock ? "TrayRequestDock" : message == TrayBeginMessage ? "TrayBeginMessage" : diff --git a/cmd/tray/main.c b/cmd/tray/main.c index 9cbce8b1..5e4e22f3 100644 --- a/cmd/tray/main.c +++ b/cmd/tray/main.c @@ -33,9 +33,11 @@ cleanup_handler(int signal) { sa.sa_handler = SIG_DFL; sigaction(signal, &sa, nil); + selection_release(tray.selection); srv.running = false; switch(signal) { + case SIGINT: case SIGTERM: sa.sa_handler = cleanup_handler; sigaction(SIGALRM, &sa, nil); @@ -45,8 +47,6 @@ cleanup_handler(int signal) { break; case SIGALRM: raise(SIGTERM); - case SIGINT: - break; } } @@ -81,7 +81,7 @@ message(Selection *s, XClientMessageEvent *ev) { USED(s); Dprint("message(%A) 0x%lx\n", ev->message_type, ev->window); - Dprint("\t0x%lx, 0x%lx, 0x%lx, 0x%lx, 0x%lx\n", + Dprint("\t0x%lx, 0x%lx, 0x%ulx, 0x%ulx, 0x%ulx\n", ev->data.l[0], ev->data.l[1], ev->data.l[2], ev->data.l[3], ev->data.l[4]); w = findwin(ev->window); diff --git a/cmd/tray/selection.c b/cmd/tray/selection.c index a3509825..295fab62 100644 --- a/cmd/tray/selection.c +++ b/cmd/tray/selection.c @@ -104,10 +104,10 @@ selection_manage(char *selection, ulong time, void selection_release(Selection *s) { - if(!s->time_end) - XSetSelectionOwner(display, xatom(s->selection), None, s->time_start); if(s->cleanup) s->cleanup(s); + if(!s->time_end) + XSetSelectionOwner(display, xatom(s->selection), None, s->time_start); destroywindow(s->owner); free(s->selection); free(s); diff --git a/cmd/tray/xembed.c b/cmd/tray/xembed.c index e75d26bf..cbaf8b79 100644 --- a/cmd/tray/xembed.c +++ b/cmd/tray/xembed.c @@ -76,8 +76,16 @@ xembed_updateinfo(XEmbed *xembed) { xembed->version = res[0]; xembed->flags = res[1]; } + else { + /* Deal with a Qt system tray replacement bug. */ + xembed->flags = XEmbedMapped; + } free(res); + Dprint("xembed_updateinfo(0x%ulx) XEmbedMapped=%s\n", + xembed->w, + xembed->flags & XEmbedMapped ? "true" : "false"); + if(xembed->flags & XEmbedMapped) mapwin(xembed->w); else diff --git a/man/witray.man1 b/man/witray.man1 index a8dac897..8baa723b 100644 --- a/man/witray.man1 +++ b/man/witray.man1 @@ -39,8 +39,7 @@ to configure, and generally Just Works. vertically, respectively. Also determines from which edge of the screen windows are shunted to make room for the tray. : -n - Only create a new tray if a previous tray manager is not - already running. + Do not replace an already running system tray. : -p Sets the padding between icons and around the edge of the tray. In pixels.