From cb91e175baf446c1da7a7b5caffb29cbe190587c 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 6ac13b0..a011ccd 100644 --- a/x.c +++ b/x.c @@ -3804,8 +3804,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]) @@ -3832,10 +3836,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; }