]> git.decadent.org.uk Git - ion3.git/blobdiff - ioncore/selection.c
Update cfg_kludge_flash for Flash 10
[ion3.git] / ioncore / selection.c
index 9b5c39736869ed594a03ad927b5e17812b141a3f..896a415bc64a3c112ec98da0fda3203e5cbf258d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * ion/ioncore/selection.c
  *
- * Copyright (c) Tuomo Valkonen 1999-2007
+ * Copyright (c) Tuomo Valkonen 1999-2009
  *
  * See the included file LICENSE for details.
  */
@@ -42,7 +42,6 @@ void ioncore_handle_selection_request(XSelectionRequestEvent *ev)
     bool ok=FALSE;
     
     sev.property=None;
-    sev.target=None;
     
     if(selection_data==NULL || ev->property==None)
         goto refuse;
@@ -50,8 +49,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 +63,14 @@ 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.property=ev->property;
         XFree(prop.value);
     }
@@ -81,6 +79,7 @@ refuse:
     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);
 }
@@ -112,29 +111,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 +152,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);