[Pkg-wmaker-commits] [wmsystemtray] 04/34: Handle the case where a poorly-behaved application tries to map its own icon instead of letting us do it.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Mon Aug 24 04:01:10 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository wmsystemtray.

commit d9166293522ae1e713f2cedfa736743148d3ba37
Author: Brad Jorsch <anomie at users.sourceforge.net>
Date:   Mon Jan 18 20:06:51 2010 +0000

    Handle the case where a poorly-behaved application tries to map its own icon instead of letting us do it.
    
    
    git-svn-id: https://svn.code.sf.net/p/wmsystemtray/code@4 8177d978-5354-4e5a-a197-9fd626d94383
---
 wmsystemtray.c | 20 ++++++++++++++++++++
 wmsystemtray.h |  1 +
 2 files changed, 21 insertions(+)

diff --git a/wmsystemtray.c b/wmsystemtray.c
index 14179d7..87cbf75 100644
--- a/wmsystemtray.c
+++ b/wmsystemtray.c
@@ -155,6 +155,7 @@ struct trayicon *icon_add(int type, Window w, void *data){
     icon->parent = None;
     icon->x = 0; icon->y = 0;
     icon->mapped = False;
+    icon->visible = False;
     icon->next = NULL;
     struct trayicon **p;
     for(p = &icons; *p; p=&(*p)->next);
@@ -296,6 +297,7 @@ redo:
         void *v=catch_BadWindow_errors();
         if(!icon->mapped || i<0 || i>=icons_per_page){
             warn(DEBUG_DEBUG, "Tray icon %lx is not visible", icon->w);
+            icon->visible = False;
             if(icon->parent == None){
                 // Parent it somewhere
                 warn(DEBUG_DEBUG, "Reparenting %lx to %lx", icon->w, iconwin[0]);
@@ -304,6 +306,7 @@ redo:
             }
             XUnmapWindow(display, icon->w);
         } else {
+            icon->visible = True;
             j = i;
             switch(fill_style){
               case 0:
@@ -719,6 +722,7 @@ int main(int argc, char *argv[]){
     warn(DEBUG_DEBUG, "Entering main loop");
     while(!exitapp){
         while(XPending(display)){
+            struct trayicon *icon = NULL;
             XNextEvent(display, &ev);
             warn(DEBUG_DEBUG, "Got X event %d", ev.type);
             switch(ev.type){
@@ -728,6 +732,22 @@ int main(int argc, char *argv[]){
                 need_update=True;
                 break;
 
+              case MapNotify:
+                icon = icon_find(ev.xmap.window);
+                if(icon && !icon->visible){
+                    warn(DEBUG_WARN, "A poorly-behaved application tried to map window %lx!", ev.xmap.window);
+                    need_update=True;
+                }
+                break;
+
+              case UnmapNotify:
+                icon = icon_find(ev.xunmap.window);
+                if(icon && icon->visible){
+                    warn(DEBUG_WARN, "A poorly-behaved application tried to unmap window %lx!", ev.xmap.window);
+                    need_update=True;
+                }
+                break;
+
               case DestroyNotify:
                 if(exitapp) break;
                 if(selwindow==ev.xdestroywindow.window){
diff --git a/wmsystemtray.h b/wmsystemtray.h
index 1eca54f..cec0de9 100644
--- a/wmsystemtray.h
+++ b/wmsystemtray.h
@@ -14,6 +14,7 @@ struct trayicon {
 
     /* private */
     Bool mapped;
+    Bool visible;
     Window parent;
     int x, y;
     struct trayicon *next;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmsystemtray.git



More information about the Pkg-wmaker-commits mailing list