paperview icon indicating copy to clipboard operation
paperview copied to clipboard

Pause Rendering

Open shakna-israel opened this issue 5 years ago • 2 comments

Would it be possible to use SDL_WINDOWEVENT_HIDDEN and SDL_WINDOWEVENT_EXPOSED/SDL_WINDOWEVENT_SHOWN to pause rendering when the background isn't in view, and so save same cycles/battery?

I think it might work during the poll loop watching for the quit event, at a glance.

shakna-israel avatar Aug 03 '20 03:08 shakna-israel

I had a look, but not much luck. Seems like the background is always visible according to SDL2

glouw avatar Aug 05 '20 01:08 glouw

Hi, Maybe you can take a similar approach to what Anipaper does: instead of dealing with SDL2 for this, use X11:

From time to time (in a separate thread or not), get the position of all non-minimized windows and calculate the area (with overlap, the Line Sweep algorithm does this) of all of them: if the occupied area reaches a certain threshold (say, 70% of the entire screen), the program pauses, otherwise resumes execution.

The main idea is that if the wallpaper is only partially visible (either through multiple windows covering the screen or through a full-screen window), the wallpaper does not need to be animated.

You can check the polling thread here and the calculation of the area used here.


Sorry to bother you on a relatively old issue, but I like paperview a lot, so I feel obligated to say something when I have something to contribute.

Anyway, paperview's performance is already amazing as it is, so I don't know if it's worth adding more complexity to the code.

Theldus avatar Feb 08 '22 00:02 Theldus