From 9e6431dc3bd121b1994961c68374b4e17db29444 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 26 Jun 2023 15:54:57 +0200 Subject: tinywl: enable new outputs --- tinywl/tinywl.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tinywl/tinywl.c b/tinywl/tinywl.c index 80f08e70..8324c500 100644 --- a/tinywl/tinywl.c +++ b/tinywl/tinywl.c @@ -596,6 +596,11 @@ static void server_new_output(struct wl_listener *listener, void *data) { * and our renderer. Must be done once, before commiting the output */ wlr_output_init_render(wlr_output, server->allocator, server->renderer); + /* The output may be disabled, switch it on. */ + struct wlr_output_state state; + wlr_output_state_init(&state); + wlr_output_state_set_enabled(&state, true); + /* Some backends don't have modes. DRM+KMS does, and we need to set a mode * before we can use the output. The mode is a tuple of (width, height, * refresh rate), and each monitor supports only a specific set of modes. We @@ -603,17 +608,13 @@ static void server_new_output(struct wl_listener *listener, void *data) { * would let the user configure it. */ struct wlr_output_mode *mode = wlr_output_preferred_mode(wlr_output); if (mode != NULL) { - struct wlr_output_state state; - wlr_output_state_init(&state); wlr_output_state_set_mode(&state, mode); - wlr_output_state_set_enabled(&state, true); - if (!wlr_output_commit_state(wlr_output, &state)) { - wlr_output_state_finish(&state); - return; - } - wlr_output_state_finish(&state); } + /* Atomically applies the new output state. */ + wlr_output_commit_state(wlr_output, &state); + wlr_output_state_finish(&state); + /* Allocates and configures our state for this output */ struct tinywl_output *output = calloc(1, sizeof(struct tinywl_output)); -- cgit v1.2.3