X-Git-Url: https://git.decadent.org.uk/gitweb/?p=ion3.git;a=blobdiff_plain;f=ioncore%2Fselection.c;h=1ebbb43be3070c5e13be04b3a070bee342be5d09;hp=9b5c39736869ed594a03ad927b5e17812b141a3f;hb=214381793227e299ae1e72caa24ad2cfde029ef1;hpb=1cd244db6df1337d594b9e2456c735cbc28aea6c diff --git a/ioncore/selection.c b/ioncore/selection.c index 9b5c397..1ebbb43 100644 --- a/ioncore/selection.c +++ b/ioncore/selection.c @@ -50,8 +50,8 @@ void ioncore_handle_selection_request(XSelectionRequestEvent *ev) p[0]=selection_data; if(!ioncore_g.use_mb && ev->target==XA_STRING){ - Status st=XStringListToTextProperty((char **)&p, 1, &prop); - ok=st; + Status st=XStringListToTextProperty((char **)p, 1, &prop); + ok=(st!=0); }else if(ioncore_g.use_mb){ XICCEncodingStyle style; @@ -64,15 +64,15 @@ void ioncore_handle_selection_request(XSelectionRequestEvent *ev) } if(ok){ - Status st=XmbTextListToTextProperty(ioncore_g.dpy, (char **)p, 1, - style, &prop); - ok=!st; + int st=XmbTextListToTextProperty(ioncore_g.dpy, (char **)p, 1, + style, &prop); + ok=(st>=0); } } if(ok){ XSetTextProperty(ioncore_g.dpy, ev->requestor, &prop, ev->property); - sev.target=prop.encoding; + sev.target=ev->target; sev.property=ev->property; XFree(prop.value); } @@ -112,29 +112,13 @@ static void insert_selection(Window win, Atom prop) } -static void insert_cutbuffer(Window win) -{ - char *p; - int n; - - p=XFetchBytes(ioncore_g.dpy, &n); - - if(n<=0 || p==NULL) - return; - - ins(win, p, n); -} - - void ioncore_handle_selection(XSelectionEvent *ev) { Atom prop=ev->property; Window win=ev->requestor; WWindow *wwin; - if(prop==None){ - insert_cutbuffer(win); - }else{ + if(prop!=None){ insert_selection(win, prop); XDeleteProperty(ioncore_g.dpy, win, prop); } @@ -169,8 +153,6 @@ void ioncore_set_selection_n(const char *p, int n) selection_data[n]='\0'; selection_length=n; - XStoreBytes(ioncore_g.dpy, p, n); - XSetSelectionOwner(ioncore_g.dpy, CLIPATOM(ioncore_g.dpy), DefaultRootWindow(ioncore_g.dpy), CurrentTime);