Skip to content

selection edge: detect selection repaint more reliably #321

Open
@N-R-K

Description

@N-R-K

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions