From be050979684ae8779a56e4b0166cfb21d1935d35 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 22 Jun 2023 15:48:35 +0200 Subject: output: add wlr_output_state_init() This changes the semantics of wlr_output_state. Instead of having fields with uninitialized memory when missing from the committed bitflag, all fields are always initialized (and maybe NULL/empty), just like we do in wlr_surface_state. This reduces the chances of footguns when reading a field, and removes the need to check for the committed bitfield everywhere. A new wlr_output_state_init() function takes care of initializing the Pixman region. --- tinywl/tinywl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tinywl') diff --git a/tinywl/tinywl.c b/tinywl/tinywl.c index e6e3ceee..80f08e70 100644 --- a/tinywl/tinywl.c +++ b/tinywl/tinywl.c @@ -603,7 +603,8 @@ 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 = {0}; + 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)) { -- cgit v1.2.3