]> git.armaanb.net Git - dmenu.git/blobdiff - dmenu.c
drw: drw_scm_create: use Clr type
[dmenu.git] / dmenu.c
diff --git a/dmenu.c b/dmenu.c
index 1cfefcd5543e495dfe5c55309ac9666189cf3fb0..eae56850e37d6cf78b570a46b1f5abe57e3df563 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]))
@@ -467,10 +467,12 @@ paste(void)
        Atom da;
 
        /* we have been given the current selection, now insert it into input */
-       XGetWindowProperty(dpy, win, utf8, 0, (sizeof text / 4) + 1, False,
-                          utf8, &da, &di, &dl, &dl, (unsigned char **)&p);
-       insert(p, (q = strchr(p, '\n')) ? q - p : (ssize_t)strlen(p));
-       XFree(p);
+       if (XGetWindowProperty(dpy, win, utf8, 0, (sizeof text / 4) + 1, False,
+                          utf8, &da, &di, &dl, &dl, (unsigned char **)&p)
+           == Success && p) {
+               insert(p, (q = strchr(p, '\n')) ? q - p : (ssize_t)strlen(p));
+               XFree(p);
+       }
        drawmenu();
 }
 
@@ -545,6 +547,7 @@ setup(void)
        XIM xim;
        Window w, dw, *dws;
        XWindowAttributes wa;
+       XClassHint ch = {"dmenu", "dmenu"};
 #ifdef XINERAMA
        XineramaScreenInfo *info;
        Window pw;
@@ -552,9 +555,8 @@ setup(void)
 #endif
 
        /* init appearance */
-       scheme[SchemeNorm] = drw_scm_create(drw, colors[SchemeNorm], 2);
-       scheme[SchemeSel] = drw_scm_create(drw, colors[SchemeSel], 2);
-       scheme[SchemeOut] = drw_scm_create(drw, colors[SchemeOut], 2);
+       for (j = 0; j < SchemeLast; j++)
+               scheme[j] = drw_scm_create(drw, colors[j], 2);
 
        clip = XInternAtom(dpy, "CLIPBOARD",   False);
        utf8 = XInternAtom(dpy, "UTF8_STRING", False);
@@ -613,6 +615,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);