From e9edf1650b64da02612719735b250b3a4f49b40c Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Thu, 2 Feb 2017 12:40:00 -0500 Subject: [PATCH] Don't bother setting the callback if there is no selection owner --- lib/x11.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/x11.c b/lib/x11.c index 63df657..b0b20f0 100644 --- a/lib/x11.c +++ b/lib/x11.c @@ -573,6 +573,8 @@ static void selrequest(XEvent* evnt) { bool x11_getsel(int selid, void(*cbfn)(char*)) { struct XSel* sel = &(Selections[selid]); if (sel->callback) return false; + if (XGetSelectionOwner(X.display, sel->atom) == None) + return true; sel->callback = cbfn; XConvertSelection(X.display, sel->atom, SelTarget, sel->atom, X.window, CurrentTime); XFlush(X.display); -- 2.51.0