Skip to content

Commit

Permalink
core: fix missing damage when window closed
Browse files Browse the repository at this point in the history
If window is closed when fading is not enabled, the window might be destroyed
before we can add the window extent to damage.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
  • Loading branch information
yshui committed Mar 27, 2019
1 parent a56f620 commit a0d862d
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/compton.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,10 @@ static bool run_fade(session_t *ps, win **_w, unsigned steps) {
w->opacity = w->opacity_tgt;
}
if (w->opacity == w->opacity_tgt) {
// 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.
// We have reached target opacity.
// We don't call win_check_fade_finished here because that could destroy
// the window, but we still need the damage info from this window
log_debug("Fading finished for window %#010x %s", w->id, w->name);
win_check_fade_finished(ps, _w);
return false;
}

Expand Down Expand Up @@ -454,6 +452,16 @@ static win *paint_preprocess(session_t *ps, bool *fade_running) {
*fade_running = true;
}

// Add window to damaged area if its opacity changes
// If was_painted == false, and to_paint is also false, we don't care
// If was_painted == false, but to_paint is true, damage will be added in
// the loop below
if (was_painted && w->opacity != opacity_old) {
add_damage_from_win(ps, w);
}

win_check_fade_finished(ps, &w);

if (!w) {
// the window might have been destroyed because fading finished
continue;
Expand All @@ -473,14 +481,6 @@ static win *paint_preprocess(session_t *ps, bool *fade_running) {
if (was_painted && w->mode != mode_old) {
w->reg_ignore_valid = false;
}

// Add window to damaged area if its opacity changes
// If was_painted == false, and to_paint is also false, we don't care
// If was_painted == false, but to_paint is true, damage will be added in
// the loop below
if (was_painted && w->opacity != opacity_old) {
add_damage_from_win(ps, w);
}
}

// Opacity will not change, from now on.
Expand Down

0 comments on commit a0d862d

Please sign in to comment.