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
|
@ -2482,12 +2482,16 @@ static void
|
||||||
delayed_draw_callback(EV_P_ ev_idle *w, int revents) {
|
delayed_draw_callback(EV_P_ ev_idle *w, int revents) {
|
||||||
// This function is only used if we are using --swopti
|
// This function is only used if we are using --swopti
|
||||||
session_t *ps = session_ptr(w, draw_idle);
|
session_t *ps = session_ptr(w, draw_idle);
|
||||||
if (ev_is_active(&ps->delayed_draw_timer))
|
assert(ps->redraw_needed);
|
||||||
return;
|
assert(!ev_is_active(&ps->delayed_draw_timer));
|
||||||
|
|
||||||
double delay = swopti_handle_timeout(ps);
|
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);
|
return _draw_callback(EV_A_ ps, revents);
|
||||||
|
}
|
||||||
|
|
||||||
// This is a little bit hacky. When we get to this point in code, we need
|
// 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
|
// to update the screen , but we will only be updating after a delay, So
|
||||||
|
|
Loading…
Reference in New Issue