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 <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-02-20 17:37:53 +00:00
parent 9ec298305a
commit 62d4c0cbdb
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
1 changed files with 13 additions and 2 deletions

View File

@ -1982,9 +1982,20 @@ redir_stop(session_t *ps) {
// Destroy all Pictures as they expire once windows are unredirected // Destroy all Pictures as they expire once windows are unredirected
// If we don't destroy them here, looks like the resources are just // If we don't destroy them here, looks like the resources are just
// kept inaccessible somehow // kept inaccessible somehow
for (win *w = ps->list; w; w = w->next) { 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); free_paint(ps, &w->paint);
} }
}
xcb_composite_unredirect_subwindows(ps->c, ps->root, XCB_COMPOSITE_REDIRECT_MANUAL); xcb_composite_unredirect_subwindows(ps->c, ps->root, XCB_COMPOSITE_REDIRECT_MANUAL);
// Unmap overlay window // Unmap overlay window