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;