mirror of
https://github.com/yshui/picom.git
synced 2024-11-11 13:51:02 -05:00
Make sure draw_idle is stopped in all cases
Previously, compton fails to stop draw_idle in some cases when sw_opti is enabled. sw_opti is a feature that limits the draw frequence to vblank frequence. It adds a delay to drawing when the screen is updated more frequently than the vblank frequence. However when the delay is not used (i.e. the screen is updated infrequent enough), compton will start drawing the frame directly without using the delay. And specically in this case, compton will fail to stop the draw_idle, causing a callback to be called once per loop of the mainloop, resulting in high CPU usage. Fixes #92 Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
377b18a00f
commit
5e49ab0861
1 changed files with 7 additions and 3 deletions
|
@ -2482,12 +2482,16 @@ static void
|
|||
delayed_draw_callback(EV_P_ ev_idle *w, int revents) {
|
||||
// This function is only used if we are using --swopti
|
||||
session_t *ps = session_ptr(w, draw_idle);
|
||||
if (ev_is_active(&ps->delayed_draw_timer))
|
||||
return;
|
||||
assert(ps->redraw_needed);
|
||||
assert(!ev_is_active(&ps->delayed_draw_timer));
|
||||
|
||||
double delay = swopti_handle_timeout(ps);
|
||||
if (delay < 1e-6)
|
||||
if (delay < 1e-6) {
|
||||
if (!ps->o.benchmark) {
|
||||
ev_idle_stop(ps->loop, &ps->draw_idle);
|
||||
}
|
||||
return _draw_callback(EV_A_ ps, revents);
|
||||
}
|
||||
|
||||
// This is a little bit hacky. When we get to this point in code, we need
|
||||
// to update the screen , but we will only be updating after a delay, So
|
||||
|
|
Loading…
Reference in a new issue