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
This commit is contained in:
Brad Jorsch 2010-01-18 20:06:51 +00:00
parent b9c3d053f9
commit d916629352
2 changed files with 21 additions and 0 deletions

View File

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

View File

@ -14,6 +14,7 @@ struct trayicon {
/* private */
Bool mapped;
Bool visible;
Window parent;
int x, y;
struct trayicon *next;