[hackers] [dmenu] fixed paste || Connor Lane Smith

From: <hg_AT_suckless.org>
Date: Wed, 11 Aug 2010 14:02:07 +0000 (UTC)

changeset: 358:8e45498dc735
tag: tip
user: Connor Lane Smith <cls_AT_lubutu.com>
date: Wed Aug 11 15:02:03 2010 +0100
files: dmenu.c
description:
fixed paste

diff -r 8dd995a51693 -r 8e45498dc735 dmenu.c
--- a/dmenu.c Wed Aug 11 14:24:25 2010 +0100
+++ b/dmenu.c Wed Aug 11 15:02:03 2010 +0100
@@ -32,7 +32,7 @@
 static void insert(const char *s, ssize_t n);
 static void keypress(XKeyEvent *ev);
 static void match(void);
-static void paste(void);
+static void paste(Atom atom);
 static void readstdin(void);
 static void run(void);
 static void setup(void);
@@ -52,7 +52,7 @@
 static unsigned int promptw;
 static unsigned long normcol[ColLast];
 static unsigned long selcol[ColLast];
-static Atom utf8;
+static Atom clip, utf8;
 static Bool topbar = True;
 static DC *dc;
 static Item *items = NULL;
@@ -228,7 +228,7 @@
                         insert(NULL, 1-n);
                         break;
                 case XK_y: /* paste selection */
- XConvertSelection(dc->dpy, XA_PRIMARY, utf8, None, win, CurrentTime);
+ XConvertSelection(dc->dpy, XA_PRIMARY, utf8, clip, win, CurrentTime);
                         return;
                 }
         }
@@ -371,13 +371,13 @@
 }
 
 void
-paste(void) {
+paste(Atom atom) {
         char *p, *q;
         int di;
         unsigned long dl;
         Atom da;
 
- XGetWindowProperty(dc->dpy, win, utf8, 0, sizeof text - cursor, True,
+ XGetWindowProperty(dc->dpy, win, atom, 0, sizeof text - cursor, False,
                            utf8, &da, &di, &dl, &dl, (unsigned char **)&p);
         insert(p, (q = strchr(p, '\n')) ? q-p : strlen(p));
         XFree(p);
@@ -415,8 +415,8 @@
                         keypress(&ev.xkey);
                         break;
                 case SelectionNotify:
- if(ev.xselection.property == utf8)
- paste();
+ if(ev.xselection.property != None)
+ paste(ev.xselection.property);
                         break;
                 case VisibilityNotify:
                         if(ev.xvisibility.state != VisibilityUnobscured)
@@ -437,6 +437,7 @@
         screen = DefaultScreen(dc->dpy);
         root = RootWindow(dc->dpy, screen);
         utf8 = XInternAtom(dc->dpy, "UTF8_STRING", False);
+ clip = XInternAtom(dc->dpy, "_DMENU_STRING", False);
 
         normcol[ColBG] = getcolor(dc, normbgcolor);
         normcol[ColFG] = getcolor(dc, normfgcolor);
Received on Wed Aug 11 2010 - 16:02:07 CEST

This archive was generated by hypermail 2.2.0 : Wed Aug 11 2010 - 16:12:04 CEST