Skip to content

Commit

Permalink
Make sure draw_idle is stopped in all cases
Browse files Browse the repository at this point in the history
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 chjj#92

Signed-off-by: Yuxuan Shui <[email protected]>
  • Loading branch information
yshui committed Jan 25, 2019
1 parent 377b18a commit 5e49ab0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/compton.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5e49ab0

Please sign in to comment.