[hackers] [wmii] Deal with a particular Qt systray replacement bug. Cleanup a bit more politely on sigterm/sigint. || Kris Maglione

From: <hg_AT_suckless.org>
Date: Tue, 20 Sep 2011 04:06:58 +0200 (CEST)

changeset: 2805:b3911f39ceda
tag: tip
user: Kris Maglione <kris_AT_suckless.org>
date: Mon Sep 19 22:06:50 2011 -0400
files: cmd/tray/Makefile cmd/tray/client.c cmd/tray/main.c cmd/tray/selection.c cmd/tray/xembed.c man/witray.man1
description:
Deal with a particular Qt systray replacement bug. Cleanup a bit more politely on sigterm/sigint.

diff -r ecf4c7217989 -r b3911f39ceda cmd/tray/Makefile
--- a/cmd/tray/Makefile Mon Sep 19 20:24:32 2011 -0400
+++ b/cmd/tray/Makefile Mon Sep 19 22:06:50 2011 -0400
@@ -5,7 +5,7 @@
 main.c: $(ROOT)/mk/wmii.mk
 
 TARG = witray
-HFILES= dat.h fns.h
+HFILES= dat.h fns.h selection.h
 
 PACKAGES += $(X11PACKAGES)
 
diff -r ecf4c7217989 -r b3911f39ceda cmd/tray/client.c
--- a/cmd/tray/client.c Mon Sep 19 20:24:32 2011 -0400
+++ b/cmd/tray/client.c Mon Sep 19 22:06:50 2011 -0400
@@ -27,7 +27,7 @@
         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 @@
 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 -r ecf4c7217989 -r b3911f39ceda cmd/tray/main.c
--- a/cmd/tray/main.c Mon Sep 19 20:24:32 2011 -0400
+++ b/cmd/tray/main.c Mon Sep 19 22:06:50 2011 -0400
@@ -33,9 +33,11 @@
         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 @@
                 break;
         case SIGALRM:
                 raise(SIGTERM);
- case SIGINT:
- break;
         }
 }
 
@@ -81,7 +81,7 @@
         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 -r ecf4c7217989 -r b3911f39ceda cmd/tray/selection.c
--- a/cmd/tray/selection.c Mon Sep 19 20:24:32 2011 -0400
+++ b/cmd/tray/selection.c Mon Sep 19 22:06:50 2011 -0400
@@ -104,10 +104,10 @@
 
 void
 selection_release(Selection *s) {
+ if(s->cleanup)
+ s->cleanup(s);
         if(!s->time_end)
                 XSetSelectionOwner(display, xatom(s->selection), None, s->time_start);
- if(s->cleanup)
- s->cleanup(s);
         destroywindow(s->owner);
         free(s->selection);
         free(s);
diff -r ecf4c7217989 -r b3911f39ceda cmd/tray/xembed.c
--- a/cmd/tray/xembed.c Mon Sep 19 20:24:32 2011 -0400
+++ b/cmd/tray/xembed.c Mon Sep 19 22:06:50 2011 -0400
@@ -76,8 +76,16 @@
                 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 -r ecf4c7217989 -r b3911f39ceda man/witray.man1
--- a/man/witray.man1 Mon Sep 19 20:24:32 2011 -0400
+++ b/man/witray.man1 Mon Sep 19 22:06:50 2011 -0400
@@ -39,8 +39,7 @@
         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.
Received on Tue Sep 20 2011 - 04:06:58 CEST

This archive was generated by hypermail 2.2.0 : Tue Sep 20 2011 - 04:12:05 CEST