From 49ac4d1e14a0ac9c45c44efe9ae97bf1c4971f76 Mon Sep 17 00:00:00 2001 From: veltza <106755522+veltza@users.noreply.github.com> Date: Tue, 22 Apr 2025 10:53:53 +0300 Subject: [PATCH] Prevent SelectionRequests from interfering with blinking cursor (#173) Some old clipboard managers, such as greenclip and parcellite, constantly poll applications with SelectionRequest events, which breaks the internal timer and blinking cursor. This fix prevents these events from causing any disruption. Fixes #172 --- x.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/x.c b/x.c index 1d5d1e9..249e056 100644 --- a/x.c +++ b/x.c @@ -3851,8 +3851,12 @@ run(void) xev = 0; while (XPending(xw.dpy)) { - xev = 1; XNextEvent(xw.dpy, &ev); + #if BLINKING_CURSOR_PATCH + xev = (!xev || xev == SelectionRequest) ? ev.type : xev; + #else + xev = 1; + #endif // BLINKING_CURSOR_PATCH if (XFilterEvent(&ev, None)) continue; if (handler[ev.type]) @@ -3879,10 +3883,10 @@ run(void) if (!drawing) { trigger = now; #if BLINKING_CURSOR_PATCH - if (IS_SET(MODE_BLINK)) { - win.mode ^= MODE_BLINK; + if (xev != SelectionRequest) { + win.mode &= ~MODE_BLINK; + lastblink = now; } - lastblink = now; #endif // BLINKING_CURSOR_PATCH drawing = 1; }