Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

selection edge: detect selection repaint more reliably #321

Open
N-R-K opened this issue May 26, 2023 · 0 comments
Open

selection edge: detect selection repaint more reliably #321

N-R-K opened this issue May 26, 2023 · 0 comments

Comments

@N-R-K
Copy link
Collaborator

N-R-K commented May 26, 2023

Currently we have the following going on in the destroy part of selection-edge:

scrot/src/selection_edge.c

Lines 142 to 147 in 1a9964a

/* HACK: although we recived a DestroyNotify event, the frame still
* might not have been updated. a compositor might also buffer frames
* adding latency. so wait a bit for the screen to update and the
* selection borders to go away. */
struct timespec t = { .tv_nsec = 80 * 1000L * 1000L };
while (nanosleep(&t, &t) < 0 && errno == EINTR);

Instead of sleeping, we might want to detect whether the screen got repainted or not more reliably. This way, users who have a fast/low-latency system won't have to unnecessarily pay for the ~80ms sleep.

The XDamage extension might work. But my previous experience with it wasn't very fruitful.

And if we cannot detect it more reliably, then we might want to listen for vblank rather than sleeping a fixed amount. Listening for about 4~5 vblanks should be okay, on 60hz monitors that'll be around 80ms, on faster 240hz it'll be about ~21ms. (Unfortunately, I don't know any simple way to listen for vblanks on X without depending on opengl/GLX).

Some other related discussion: #274 #304

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant