Deal with a particular Qt systray replacement bug. Cleanup a bit more politely on sigterm/sigint.

This commit is contained in:
Kris Maglione 2011-09-19 22:06:50 -04:00
parent 7eb2bef1bd
commit 6594959ce8
6 changed files with 17 additions and 10 deletions

View File

@ -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)

View File

@ -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" :

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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 <padding>
Sets the padding between icons and around the edge of the
tray. In pixels.