output: refuse to commit a buffer or modeset a disabled output

References: https://github.com/swaywm/wlroots/issues/1780#issuecomment-518938390
This commit is contained in:
Simon Ser 2019-12-27 11:59:15 +01:00 committed by Drew DeVault
parent b5597f5b44
commit 8fc16890c7
3 changed files with 39 additions and 6 deletions

View file

@ -483,7 +483,7 @@ bool wlr_output_commit(struct wlr_output *output) {
if (output->pending.committed & WLR_OUTPUT_STATE_BUFFER) {
if (output->frame_pending) {
wlr_log(WLR_ERROR, "Tried to commit a buffer while a frame is pending");
return false;
goto error;
}
if (output->idle_frame != NULL) {
wl_event_source_remove(output->idle_frame);
@ -491,6 +491,20 @@ bool wlr_output_commit(struct wlr_output *output) {
}
}
bool enabled = output->enabled;
if (output->pending.committed & WLR_OUTPUT_STATE_ENABLED) {
enabled = output->pending.enabled;
}
if (!enabled && output->pending.committed & WLR_OUTPUT_STATE_BUFFER) {
wlr_log(WLR_ERROR, "Tried to commit a buffer on a disabled output");
goto error;
}
if (!enabled && output->pending.committed & WLR_OUTPUT_STATE_MODE) {
wlr_log(WLR_ERROR, "Tried to modeset a disabled output");
goto error;
}
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
@ -554,6 +568,14 @@ bool wlr_output_commit(struct wlr_output *output) {
output_state_clear(&output->pending);
return true;
error:
output_state_clear(&output->pending);
return false;
}
void wlr_output_rollback(struct wlr_output *output) {
output_state_clear(&output->pending);
}
bool wlr_output_attach_buffer(struct wlr_output *output,