/*
* ion/ioncore/selection.c
*
- * Copyright (c) Tuomo Valkonen 1999-2007.
+ * Copyright (c) Tuomo Valkonen 1999-2008.
*
* See the included file LICENSE for details.
*/
bool ok=FALSE;
sev.property=None;
- sev.target=None;
if(selection_data==NULL || ev->property==None)
goto refuse;
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;
}
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.property=ev->property;
XFree(prop.value);
}
sev.type=SelectionNotify;
sev.requestor=ev->requestor;
sev.selection=ev->selection;
+ sev.target=ev->target;
sev.time=ev->time;
XSendEvent(ioncore_g.dpy, ev->requestor, False, 0L, (XEvent*)&sev);
}
}
-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);
}
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);