X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=dmenu.c;h=eae56850e37d6cf78b570a46b1f5abe57e3df563;hb=f0a5b75d6a0d2a62da45e9f65d92ea4a6a2d5831;hp=d605ab494dbf8d5e6ed47041a66fbfb950d8cdfe;hpb=5cd66e2c6ca6a82e59927d495498fa6e478594d6;p=dmenu.git diff --git a/dmenu.c b/dmenu.c index d605ab4..eae5685 100644 --- a/dmenu.c +++ b/dmenu.c @@ -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);