Systray: Fix BadWindow (because of unmap event) and segfault at pressing button

This commit is contained in:
Martin Duquesnoy 2010-07-22 22:07:26 +02:00
parent 908978cca1
commit fdb1d2c748
4 changed files with 16 additions and 25 deletions

View File

@ -350,7 +350,7 @@ destroynotify(XDestroyWindowEvent *ev)
else if((s = systray_find(ev->window)))
{
setwinstate(s->win, WithdrawnState);
systray_del(s->win);
systray_del(s);
systray_update();
}
@ -480,20 +480,11 @@ keypress(XKeyPressedEvent *ev)
void
mappingnotify(XMappingEvent *ev)
{
Systray *s;
XRefreshKeyboardMapping(ev);
if(ev->request == MappingKeyboard)
grabkeys();
if(!(s = systray_find(ev->window)))
{
setwinstate(s->win, NormalState);
ewmh_send_message(s->win, s->win, "_XEMBED", CurrentTime, XEMBED_WINDOW_ACTIVATE, 0, 0, 0);
}
return;
}
@ -650,8 +641,7 @@ unmapnotify(XUnmapEvent *ev)
if((s = systray_find(ev->window)))
{
setwinstate(s->win, WithdrawnState);
systray_del(s->win);
systray_del(s);
systray_update();
}

View File

@ -97,7 +97,7 @@ systray_add(Window win)
setwinstate(s->win, WithdrawnState);
XSelectInput(dpy, s->win, StructureNotifyMask | PropertyChangeMask| EnterWindowMask | FocusChangeMask);
XReparentWindow(dpy, s->win, traywin, 0, 0);
XReparentWindow(dpy, s->win, traywin, 0, 0);
ewmh_send_message(s->win, s->win, "_XEMBED", CurrentTime, XEMBED_EMBEDDED_NOTIFY, 0, traywin, 0);
@ -112,15 +112,14 @@ systray_add(Window win)
}
void
systray_del(Window win)
systray_del(Systray *s)
{
Systray *t, **ss;
Systray **ss;
if(!(t = systray_find(win)))
return;
for(ss = &trayicons; *ss && *ss != s; ss = &(*ss)->next);
*ss = s->next;
for(ss = &trayicons; *ss && *ss != t; ss = &(*ss)->next);
*ss = t->next;
IFREE(s);
return;
}

View File

@ -210,7 +210,6 @@ scan(void)
Atom rt;
int s, rf, tag = -1, screen = -1, free = -1;
ulong ir, il;
long flags;
uchar *ret;
Client *c;
@ -218,12 +217,14 @@ scan(void)
if(XQueryTree(dpy, ROOT, &usl, &usl2, &w, &n))
for(i = n - 1; i != -1; --i)
if(XGetWindowAttributes(dpy, w[i], &wa)
&& !(wa.override_redirect || XGetTransientForHint(dpy, w[i], &usl))
{
XGetWindowAttributes(dpy, w[i], &wa);
if(!wa.override_redirect/* || XGetTransientForHint(dpy, w[i], &usl))*/
&& wa.map_state == IsViewable)
{
if((flags = ewmh_get_xembed_state(w[i])))
systray_add(w[i]);
if(ewmh_get_xembed_state(w[i]))
systray_add(w[i]);
if(XGetWindowProperty(dpy, w[i], ATOM("_WMFS_TAG"), 0, 32,
False, XA_CARDINAL, &rt, &rf, &ir, &il, &ret) == Success && ret)
@ -257,6 +258,7 @@ scan(void)
client_update_attributes(c);
}
}
/* Set update layout request */
for(c = clients; c; c = c->next)

View File

@ -352,7 +352,7 @@ Bool systray_acquire(void);
void systray_init(void);
void systray_kill(void);
void systray_add(Window win);
void systray_del(Window win);
void systray_del(Systray *s);
void systray_configure(Systray *s);
void systray_state(Systray *s);
void systray_freeicons(void);