From 62d4c0cbdb7ebc68cba321a249efcb7ecff7339e Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Wed, 20 Feb 2019 17:37:53 +0000 Subject: [PATCH] Cut fading short if we decide to unredirect the screen Previously if we unredirect the screen while a fading is in progress, we will "resume" the fading when we redirect the screen again. This is usually fine unless the window being faded out is destroyed. we still tries to fade it out, but since we don't have the pixmap of the window anymore (freed by unredirect), we will generate lots of errors until the window is completely "faded out". Also this change makes it easy to reason about things. Now we know when the screen is unredirected, all the windows can either be in MAPPED or UNMAPPED state, nothing else. Signed-off-by: Yuxuan Shui --- src/compton.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/compton.c b/src/compton.c index a2fc2fb..630106a 100644 --- a/src/compton.c +++ b/src/compton.c @@ -1982,8 +1982,19 @@ redir_stop(session_t *ps) { // Destroy all Pictures as they expire once windows are unredirected // If we don't destroy them here, looks like the resources are just // kept inaccessible somehow - for (win *w = ps->list; w; w = w->next) { - free_paint(ps, &w->paint); + for (win *w = ps->list, *next; w; w = next) { + next = w->next; + // Wrapping up fading in progress + if (w->opacity != w->opacity_tgt) { + assert(w->state != WSTATE_UNMAPPED && w->state != WSTATE_MAPPED); + w->opacity = w->opacity_tgt; + win_check_fade_finished(ps, &w); + } + + // `w` might be freed by win_check_fade_finished + if (w) { + free_paint(ps, &w->paint); + } } xcb_composite_unredirect_subwindows(ps->c, ps->root, XCB_COMPOSITE_REDIRECT_MANUAL);