diff options
| -rw-r--r-- | dmenu.c | 15 |
1 files changed, 8 insertions, 7 deletions
| @@ -32,7 +32,7 @@ static void grabkeyboard(void); | |||
| 32 | static void insert(const char *s, ssize_t n); | 32 | static void insert(const char *s, ssize_t n); |
| 33 | static void keypress(XKeyEvent *ev); | 33 | static void keypress(XKeyEvent *ev); |
| 34 | static void match(void); | 34 | static void match(void); |
| 35 | static void paste(void); | 35 | static void paste(Atom atom); |
| 36 | static void readstdin(void); | 36 | static void readstdin(void); |
| 37 | static void run(void); | 37 | static void run(void); |
| 38 | static void setup(void); | 38 | static void setup(void); |
| @@ -52,7 +52,7 @@ static unsigned int lines = 0; | |||
| 52 | static unsigned int promptw; | 52 | static unsigned int promptw; |
| 53 | static unsigned long normcol[ColLast]; | 53 | static unsigned long normcol[ColLast]; |
| 54 | static unsigned long selcol[ColLast]; | 54 | static unsigned long selcol[ColLast]; |
| 55 | static Atom utf8; | 55 | static Atom clip, utf8; |
| 56 | static Bool topbar = True; | 56 | static Bool topbar = True; |
| 57 | static DC *dc; | 57 | static DC *dc; |
| 58 | static Item *items = NULL; | 58 | static Item *items = NULL; |
| @@ -228,7 +228,7 @@ keypress(XKeyEvent *ev) { | |||
| 228 | insert(NULL, 1-n); | 228 | insert(NULL, 1-n); |
| 229 | break; | 229 | break; |
| 230 | case XK_y: /* paste selection */ | 230 | case XK_y: /* paste selection */ |
| 231 | XConvertSelection(dc->dpy, XA_PRIMARY, utf8, None, win, CurrentTime); | 231 | XConvertSelection(dc->dpy, XA_PRIMARY, utf8, clip, win, CurrentTime); |
| 232 | return; | 232 | return; |
| 233 | } | 233 | } |
| 234 | } | 234 | } |
| @@ -371,13 +371,13 @@ match(void) { | |||
| 371 | } | 371 | } |
| 372 | 372 | ||
| 373 | void | 373 | void |
| 374 | paste(void) { | 374 | paste(Atom atom) { |
| 375 | char *p, *q; | 375 | char *p, *q; |
| 376 | int di; | 376 | int di; |
| 377 | unsigned long dl; | 377 | unsigned long dl; |
| 378 | Atom da; | 378 | Atom da; |
| 379 | 379 | ||
| 380 | XGetWindowProperty(dc->dpy, win, utf8, 0, sizeof text - cursor, True, | 380 | XGetWindowProperty(dc->dpy, win, atom, 0, sizeof text - cursor, False, |
| 381 | utf8, &da, &di, &dl, &dl, (unsigned char **)&p); | 381 | utf8, &da, &di, &dl, &dl, (unsigned char **)&p); |
| 382 | insert(p, (q = strchr(p, '\n')) ? q-p : strlen(p)); | 382 | insert(p, (q = strchr(p, '\n')) ? q-p : strlen(p)); |
| 383 | XFree(p); | 383 | XFree(p); |
| @@ -415,8 +415,8 @@ run(void) { | |||
| 415 | keypress(&ev.xkey); | 415 | keypress(&ev.xkey); |
| 416 | break; | 416 | break; |
| 417 | case SelectionNotify: | 417 | case SelectionNotify: |
| 418 | if(ev.xselection.property == utf8) | 418 | if(ev.xselection.property != None) |
| 419 | paste(); | 419 | paste(ev.xselection.property); |
| 420 | break; | 420 | break; |
| 421 | case VisibilityNotify: | 421 | case VisibilityNotify: |
| 422 | if(ev.xvisibility.state != VisibilityUnobscured) | 422 | if(ev.xvisibility.state != VisibilityUnobscured) |
| @@ -437,6 +437,7 @@ setup(void) { | |||
| 437 | screen = DefaultScreen(dc->dpy); | 437 | screen = DefaultScreen(dc->dpy); |
| 438 | root = RootWindow(dc->dpy, screen); | 438 | root = RootWindow(dc->dpy, screen); |
| 439 | utf8 = XInternAtom(dc->dpy, "UTF8_STRING", False); | 439 | utf8 = XInternAtom(dc->dpy, "UTF8_STRING", False); |
| 440 | clip = XInternAtom(dc->dpy, "_DMENU_STRING", False); | ||
| 440 | 441 | ||
| 441 | normcol[ColBG] = getcolor(dc, normbgcolor); | 442 | normcol[ColBG] = getcolor(dc, normbgcolor); |
| 442 | normcol[ColFG] = getcolor(dc, normfgcolor); | 443 | normcol[ColFG] = getcolor(dc, normfgcolor); |
