X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=scrotwm.c;h=520f15624a421e8191c0075c9698cade8a4fec98;hb=a2a8bae91b7dcc662140ef915f8da5d104feb91c;hp=7c076489365cda6a5b8ea14de22b4f7dcfb01e08;hpb=de65c2a567bd5b9b4274d7ac5bed3cb833c409a5;p=spectrwm.git diff --git a/scrotwm.c b/scrotwm.c index 7c07648..520f156 100644 --- a/scrotwm.c +++ b/scrotwm.c @@ -219,6 +219,7 @@ struct ws_win { struct swm_screen *s; /* always valid, never changes */ XWindowAttributes wa; XSizeHints sh; + XClassHint ch; }; TAILQ_HEAD(ws_win_list, ws_win); @@ -1770,7 +1771,6 @@ manage_window(Window id) Window trans; struct workspace *ws; struct ws_win *win; - XClassHint ch; int format, i, ws_idx; unsigned long nitems, bytes; Atom ws_idx_atom = 0, type; @@ -1834,26 +1834,18 @@ manage_window(Window id) fprintf(stderr, "manage window: %d x %d y %d w %d h %d\n", win->id, win->g.x, win->g.y, win->g.w, win->g.h); */ - bzero(&ch, sizeof ch); - if (XGetClassHint(display, win->id, &ch)) { + if (XGetClassHint(display, win->id, &win->ch)) { DNPRINTF(SWM_D_CLASS, "class: %s name: %s\n", - ch.res_class, ch.res_name); + win->ch.res_class, win->ch.res_name); for (i = 0; quirks[i].class != NULL && quirks[i].name != NULL && quirks[i].quirk != 0; i++){ - if (!strcmp(ch.res_class, quirks[i].class) && - !strcmp(ch.res_name, quirks[i].name)) { + if (!strcmp(win->ch.res_class, quirks[i].class) && + !strcmp(win->ch.res_name, quirks[i].name)) { DNPRINTF(SWM_D_CLASS, "found: %s name: %s\n", - ch.res_class, ch.res_name); + win->ch.res_class, win->ch.res_name); if (quirks[i].quirk & SWM_Q_FLOAT) win->floating = 1; } -#if 0 - /* XXX logic says to do this but get a double free */ - if (ch.res_class) - XFree(ch.res_class); - if (ch.res_name) - XFree(ch.res_name); -#endif } } @@ -1965,6 +1957,10 @@ destroynotify(XEvent *e) focus_win(ws->focus); TAILQ_REMOVE(&ws->winlist, win, entry); set_win_state(win, WithdrawnState); + if (win->ch.res_class) + XFree(win->ch.res_class); + if (win->ch.res_name) + XFree(win->ch.res_name); free(win); stack(); }