fixed paste
402dc2bc
1 file(s) · +8 −7
| 32 | 32 | static void insert(const char *s, ssize_t n); |
|
| 33 | 33 | static void keypress(XKeyEvent *ev); |
|
| 34 | 34 | static void match(void); |
|
| 35 | - | static void paste(void); |
|
| 35 | + | static void paste(Atom atom); |
|
| 36 | 36 | static void readstdin(void); |
|
| 37 | 37 | static void run(void); |
|
| 38 | 38 | static void setup(void); |
|
| 52 | 52 | static unsigned int promptw; |
|
| 53 | 53 | static unsigned long normcol[ColLast]; |
|
| 54 | 54 | static unsigned long selcol[ColLast]; |
|
| 55 | - | static Atom utf8; |
|
| 55 | + | static Atom clip, utf8; |
|
| 56 | 56 | static Bool topbar = True; |
|
| 57 | 57 | static DC *dc; |
|
| 58 | 58 | static Item *items = NULL; |
|
| 228 | 228 | insert(NULL, 1-n); |
|
| 229 | 229 | break; |
|
| 230 | 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 | 232 | return; |
|
| 233 | 233 | } |
|
| 234 | 234 | } |
|
| 371 | 371 | } |
|
| 372 | 372 | ||
| 373 | 373 | void |
|
| 374 | - | paste(void) { |
|
| 374 | + | paste(Atom atom) { |
|
| 375 | 375 | char *p, *q; |
|
| 376 | 376 | int di; |
|
| 377 | 377 | unsigned long dl; |
|
| 378 | 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 | 381 | utf8, &da, &di, &dl, &dl, (unsigned char **)&p); |
|
| 382 | 382 | insert(p, (q = strchr(p, '\n')) ? q-p : strlen(p)); |
|
| 383 | 383 | XFree(p); |
|
| 415 | 415 | keypress(&ev.xkey); |
|
| 416 | 416 | break; |
|
| 417 | 417 | case SelectionNotify: |
|
| 418 | - | if(ev.xselection.property == utf8) |
|
| 419 | - | paste(); |
|
| 418 | + | if(ev.xselection.property != None) |
|
| 419 | + | paste(ev.xselection.property); |
|
| 420 | 420 | break; |
|
| 421 | 421 | case VisibilityNotify: |
|
| 422 | 422 | if(ev.xvisibility.state != VisibilityUnobscured) |
|
| 437 | 437 | screen = DefaultScreen(dc->dpy); |
|
| 438 | 438 | root = RootWindow(dc->dpy, screen); |
|
| 439 | 439 | utf8 = XInternAtom(dc->dpy, "UTF8_STRING", False); |
|
| 440 | + | clip = XInternAtom(dc->dpy, "_DMENU_STRING", False); |
|
| 440 | 441 | ||
| 441 | 442 | normcol[ColBG] = getcolor(dc, normbgcolor); |
|
| 442 | 443 | normcol[ColFG] = getcolor(dc, normfgcolor); |
|