naelstrof / slop

slop (Select Operation) is an application that queries for a selection from the user and prints the region to stdout.
Other
871 stars 58 forks source link

Support for high refresh rate monitors #168

Open foxpy opened 1 year ago

foxpy commented 1 year ago

On a high refresh rate monitor (in @iambeingtracked's case 144hz) the selection GUI doesn't act as smooth as it should act with such a refresh rate.

Supersedes https://github.com/naelstrof/maim/issues/278

N-R-K commented 1 year ago

Likely source of the issue:

https://github.com/naelstrof/slop/blob/864bdb2ce8bd6403e9e38c5c400cb93138952407/src/slop.cpp#L190-L192

foxpy commented 1 year ago

The XSync function flushes the output buffer and then waits until all requests have been received and processed by the X server.

I think the fix would be to replace

 XFlush(x11->display);
 std::this_thread::sleep_for(std::chrono::milliseconds(10));

with a simple

 XSync(x11->display, False);

CC @naelstrof

naelstrof commented 1 year ago

Yeah that seems like it'll work, someone make a pull request and I'll accept it

N-R-K commented 1 year ago

I'm not sure if XSync the "right" fix here or not. Ideally you'd want to sync with the vblank - using something like XPresent. (But I don't have any first hand experience in doing that, so can't offer anything more atm).

foxpy commented 1 year ago

maybe we should even use XNextEvent. slop is not a videogame, it only has to refresh screen when a new input event arrives.

though I don't have any experience, too.