]> git.mdlowis.com Git - projs/tide.git/commitdiff
Fixed X11 selection protocol. Now we respond to targets requests instead of ignoring...
authorMichael D. Lowis <mike.lowis@gentex.com>
Tue, 31 Jan 2017 17:03:49 +0000 (12:03 -0500)
committerMichael D. Lowis <mike.lowis@gentex.com>
Tue, 31 Jan 2017 17:03:49 +0000 (12:03 -0500)
lib/x11.c

index 51919d44b80eca17885aa5fd43e02b3d431b6e86..63df6570e19221b1af84f9d5dfb12c03a59f18cf 100644 (file)
--- a/lib/x11.c
+++ b/lib/x11.c
@@ -542,17 +542,32 @@ static void selrequest(XEvent* evnt) {
     XEvent s;
     struct XSel* sel = selfetch( evnt->xselectionrequest.selection );
     s.xselection.type      = SelectionNotify;
-    s.xselection.property  = evnt->xselectionrequest.property;;
-    s.xselection.requestor = evnt->xselectionrequest.requestor;;
-    s.xselection.selection = evnt->xselectionrequest.selection;;
-    s.xselection.target    = evnt->xselectionrequest.target;;
-    s.xselection.time      = evnt->xselectionrequest.time;;
-    XChangeProperty(X.display, 
-        s.xselection.requestor,
-        s.xselection.property,
-        SelTarget,
-        8, PropModeReplace, (unsigned char*)sel->text, strlen(sel->text));
-    XSendEvent(X.display, evnt->xselectionrequest.requestor, True, 0, &s);
+    s.xselection.property  = evnt->xselectionrequest.property;
+    s.xselection.requestor = evnt->xselectionrequest.requestor;
+    s.xselection.selection = evnt->xselectionrequest.selection;
+    s.xselection.target    = evnt->xselectionrequest.target;
+    s.xselection.time      = evnt->xselectionrequest.time;
+    
+    Atom target    = evnt->xselectionrequest.target;
+    Atom xatargets = XInternAtom(X.display, "TARGETS", 0);
+    Atom xastring  = XInternAtom(X.display, "STRING", 0);
+    if (target == xatargets) {
+        /* respond with the supported type */
+        XChangeProperty(
+            X.display,
+            s.xselection.requestor, 
+            s.xselection.property,
+            XA_ATOM, 32, PropModeReplace,
+            (unsigned char*)&SelTarget, 1);
+    } else if (target == SelTarget || target == xastring) {
+        XChangeProperty(
+            X.display, 
+            s.xselection.requestor,
+            s.xselection.property,
+            SelTarget, 8, PropModeReplace, 
+            (unsigned char*)sel->text, strlen(sel->text));
+    }
+    XSendEvent(X.display, s.xselection.requestor, True, 0, &s);
 }
 
 bool x11_getsel(int selid, void(*cbfn)(char*)) {