Remove session_t::fade_running

It is used more as a out variable for paint_preprocess, so make it that.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-02-12 01:53:50 +00:00
parent a826e0ce79
commit e0d394595b
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
2 changed files with 24 additions and 18 deletions

View File

@ -370,9 +370,6 @@ typedef struct session {
bool tmout_unredir_hit; bool tmout_unredir_hit;
/// Whether we need to redraw the screen /// Whether we need to redraw the screen
bool redraw_needed; bool redraw_needed;
/// Whether the program is idling. I.e. no fading, no potential window
/// changes.
bool fade_running;
/// Program start time. /// Program start time.
struct timeval time_start; struct timeval time_start;
/// The region needs to painted on next paint. /// The region needs to painted on next paint.

View File

@ -277,14 +277,15 @@ fade_timeout(session_t *ps) {
* Run fading on a window. * Run fading on a window.
* *
* @param steps steps of fading * @param steps steps of fading
* @return whether we are still in fading mode
*/ */
static void static bool
run_fade(session_t *ps, win **_w, unsigned steps) { run_fade(session_t *ps, win **_w, unsigned steps) {
win *w = *_w; win *w = *_w;
if (w->state == WSTATE_MAPPED || w->state == WSTATE_UNMAPPED) { if (w->state == WSTATE_MAPPED || w->state == WSTATE_UNMAPPED) {
// We are not fading // We are not fading
assert(w->opacity_tgt == w->opacity); assert(w->opacity_tgt == w->opacity);
return; return false;
} }
if (!win_should_fade(ps, w)) { if (!win_should_fade(ps, w)) {
@ -292,10 +293,13 @@ run_fade(session_t *ps, win **_w, unsigned steps) {
w->opacity = w->opacity_tgt; w->opacity = w->opacity_tgt;
} }
if (w->opacity == w->opacity_tgt) { if (w->opacity == w->opacity_tgt) {
// We have reached target opacity, wrapping up // We have reached target opacity, wrapping up.
// Note, we reach here after we have rendered the window with the target
// opacity at least once. If the window is destroyed because it is faded out,
// there is no need to add damage here.
log_debug("Fading finished for window %#010x %s", w->id, w->name); log_debug("Fading finished for window %#010x %s", w->id, w->name);
win_check_fade_finished(ps, _w); win_check_fade_finished(ps, _w);
return; return false;
} }
if (steps) { if (steps) {
@ -310,9 +314,9 @@ run_fade(session_t *ps, win **_w, unsigned steps) {
} }
} }
if (w->opacity != w->opacity_tgt) { // Note even if opacity == opacity_tgt, we still want to run preprocess one last
ps->fade_running = true; // time to finish state transition. So return true in that case too.
} return true;
} }
// === Error handling === // === Error handling ===
@ -469,8 +473,11 @@ find_client_win(session_t *ps, xcb_window_t w) {
} }
static win * static win *
paint_preprocess(session_t *ps, win *list) { paint_preprocess(session_t *ps, win *list, bool *fade_running) {
// XXX need better, more general name for `fade_running`. It really
// means if fade is still ongoing after the current frame is rendered
win *t = NULL, *next = NULL; win *t = NULL, *next = NULL;
*fade_running = false;
// Fading step calculation // Fading step calculation
unsigned long steps = 0L; unsigned long steps = 0L;
@ -506,7 +513,10 @@ paint_preprocess(session_t *ps, win *list) {
} }
// Run fading // Run fading
run_fade(ps, &w, steps); if (run_fade(ps, &w, steps)) {
*fade_running = true;
}
if (!w) { if (!w) {
// the window might have been destroyed because fading finished // the window might have been destroyed because fading finished
continue; continue;
@ -2084,14 +2094,14 @@ _draw_callback(EV_P_ session_t *ps, int revents) {
} }
} }
ps->fade_running = false; bool fade_running = false;
win *t = paint_preprocess(ps, ps->list); win *t = paint_preprocess(ps, ps->list, &fade_running);
ps->tmout_unredir_hit = false; ps->tmout_unredir_hit = false;
// Start/stop fade timer depends on whether window are fading // Start/stop fade timer depends on whether window are fading
if (!ps->fade_running && ev_is_active(&ps->fade_timer)) if (!fade_running && ev_is_active(&ps->fade_timer))
ev_timer_stop(ps->loop, &ps->fade_timer); ev_timer_stop(ps->loop, &ps->fade_timer);
else if (ps->fade_running && !ev_is_active(&ps->fade_timer)) { else if (fade_running && !ev_is_active(&ps->fade_timer)) {
ev_timer_set(&ps->fade_timer, fade_timeout(ps), 0); ev_timer_set(&ps->fade_timer, fade_timeout(ps), 0);
ev_timer_start(ps->loop, &ps->fade_timer); ev_timer_start(ps->loop, &ps->fade_timer);
} }
@ -2106,7 +2116,7 @@ _draw_callback(EV_P_ session_t *ps, int revents) {
exit(0); exit(0);
} }
if (!ps->fade_running) if (!fade_running)
ps->fade_time = 0L; ps->fade_time = 0L;
ps->redraw_needed = false; ps->redraw_needed = false;
@ -2299,7 +2309,6 @@ session_init(int argc, char **argv, Display *dpy, const char *config_file,
.time_start = { 0, 0 }, .time_start = { 0, 0 },
.redirected = false, .redirected = false,
.alpha_picts = NULL, .alpha_picts = NULL,
.fade_running = false,
.fade_time = 0L, .fade_time = 0L,
.ignore_head = NULL, .ignore_head = NULL,
.ignore_tail = NULL, .ignore_tail = NULL,