backend/drm: keep removed modes allocated if they are in use

After a fixed mode is removed from an output, it remains the current or
pending mode for an output until the compositor requests a different
mode. This change ensures that removed modes are not freed until the
compositor has had the opportunity to know that the mode was removed,
and in the case of the current or pending mode, that the mode is no
longer the current or pending mode.
This commit is contained in:
Daniel Playfair Cal 2021-01-10 14:46:16 +11:00
parent b7aa6ee176
commit a055f23b3b
2 changed files with 46 additions and 7 deletions

View file

@ -1255,7 +1255,13 @@ static bool update_modes(drmModeConnector *drm_conn,
previous_drm_mode->wlr_mode.preferred ? "(preferred)" : "");
wl_list_remove(&previous_drm_mode->wlr_mode.link);
free(previous_drm_mode);
// Free the removed mode unless it is the current or pending mode
if (previous_mode != wlr_conn->output.current_mode &&
!(wlr_conn->output.pending.committed & WLR_OUTPUT_STATE_MODE &&
previous_mode != wlr_conn->output.pending.mode)) {
free(previous_drm_mode);
}
}
if (drm_conn->count_modes > wl_list_length(&wlr_conn->output.modes)) {