]> git.armaanb.net Git - dwm.git/blobdiff - dwm.c
gettextprop: check result of XGetTextProperty (undefined behaviour for XFree)
[dwm.git] / dwm.c
diff --git a/dwm.c b/dwm.c
index 47823432bfe5effed3b251b2f94e12cc2aa979ca..650d19f8ebe0d07160ed5a1f79d6b267eb6baf52 100644 (file)
--- a/dwm.c
+++ b/dwm.c
@@ -910,8 +910,7 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size)
        if (!text || size == 0)
                return 0;
        text[0] = '\0';
-       XGetTextProperty(dpy, w, &name, atom);
-       if (!name.nitems)
+       if (!XGetTextProperty(dpy, w, &name, atom) || !name.nitems)
                return 0;
        if (name.encoding == XA_STRING)
                strncpy(text, (char *)name.value, size - 1);
@@ -1809,6 +1808,7 @@ updatebars(void)
                .background_pixmap = ParentRelative,
                .event_mask = ButtonPressMask|ExposureMask
        };
+       XClassHint ch = {"dwm", "dwm"};
        for (m = mons; m; m = m->next) {
                if (m->barwin)
                        continue;
@@ -1817,6 +1817,7 @@ updatebars(void)
                                CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
                XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
                XMapRaised(dpy, m->barwin);
+               XSetClassHint(dpy, m->barwin, &ch);
        }
 }