destroy output and return if first commit fails

rather than leave the monitor half-initialized

Bug: https://codeberg.org/dwl/dwl/issues/527
This commit is contained in:
Leonardo Hernández Hernández 2023-11-25 18:52:09 -06:00
parent a5e068b20a
commit 06eb09384b
No known key found for this signature in database
GPG Key ID: E538897EE11B9624

10
dwl.c
View File

@ -899,15 +899,17 @@ createmon(struct wl_listener *listener, void *data)
* the user configure it. */
wlr_output_set_mode(wlr_output, wlr_output_preferred_mode(wlr_output));
wlr_output_enable(wlr_output, 1);
if (!wlr_output_commit(wlr_output)) {
wlr_output_destroy(wlr_output);
return;
}
/* Set up event listeners */
LISTEN(&wlr_output->events.frame, &m->frame, rendermon);
LISTEN(&wlr_output->events.destroy, &m->destroy, cleanupmon);
LISTEN(&wlr_output->events.request_state, &m->request_state, requestmonstate);
wlr_output_enable(wlr_output, 1);
if (!wlr_output_commit(wlr_output))
return;
wl_list_insert(&mons, &m->link);
printstatus();