aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConnor Lane Smith <cls@lubutu.com>2010-08-11 15:02:03 +0100
committerConnor Lane Smith <cls@lubutu.com>2010-08-11 15:02:03 +0100
commit402dc2bc951a27924c963e7227932194616559f4 (patch)
tree31df225fa052a4424e930706574df36e0b088fca
parent00a60cb7b28b671ae0ba5302e3fb1cbaea6695ec (diff)
fixed paste
-rw-r--r--dmenu.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/dmenu.c b/dmenu.c
index 42022e9..f16249c 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -32,7 +32,7 @@ static void grabkeyboard(void);
32static void insert(const char *s, ssize_t n); 32static void insert(const char *s, ssize_t n);
33static void keypress(XKeyEvent *ev); 33static void keypress(XKeyEvent *ev);
34static void match(void); 34static void match(void);
35static void paste(void); 35static void paste(Atom atom);
36static void readstdin(void); 36static void readstdin(void);
37static void run(void); 37static void run(void);
38static void setup(void); 38static void setup(void);
@@ -52,7 +52,7 @@ static unsigned int lines = 0;
52static unsigned int promptw; 52static unsigned int promptw;
53static unsigned long normcol[ColLast]; 53static unsigned long normcol[ColLast];
54static unsigned long selcol[ColLast]; 54static unsigned long selcol[ColLast];
55static Atom utf8; 55static Atom clip, utf8;
56static Bool topbar = True; 56static Bool topbar = True;
57static DC *dc; 57static DC *dc;
58static Item *items = NULL; 58static 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
373void 373void
374paste(void) { 374paste(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);