Set class name on menu window
[dmenu.git] / dmenu.c
diff --git a/dmenu.c b/dmenu.c
index 1cfefcd..85e5060 100644 (file)
--- a/dmenu.c
+++ b/dmenu.c
@@ -228,7 +228,7 @@ match(void)
        len = tokc ? strlen(tokv[0]) : 0;
 
        matches = lprefix = lsubstr = matchend = prefixend = substrend = NULL;
-       textsize = strlen(text);
+       textsize = strlen(text) + 1;
        for (item = items; item && item->text; item++) {
                for (i = 0; i < tokc; i++)
                        if (!fstrstr(item->text, tokv[i]))
@@ -545,6 +545,7 @@ setup(void)
        XIM xim;
        Window w, dw, *dws;
        XWindowAttributes wa;
+       XClassHint ch = {"dmenu", "dmenu"};
 #ifdef XINERAMA
        XineramaScreenInfo *info;
        Window pw;
@@ -613,6 +614,7 @@ setup(void)
        win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
                            CopyFromParent, CopyFromParent, CopyFromParent,
                            CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
+       XSetClassHint(dpy, win, &ch);
 
        /* open input methods */
        xim = XOpenIM(dpy, NULL, NULL, NULL);