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. --- examples/simple.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'examples/simple.c') diff --git a/examples/simple.c b/examples/simple.c index fa52bce5..533e42b5 100644 --- a/examples/simple.c +++ b/examples/simple.c @@ -62,7 +62,8 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { sample->dec = inc; } - struct wlr_output_state state = {0}; + struct wlr_output_state state; + wlr_output_state_init(&state); struct wlr_render_pass *pass = wlr_output_begin_render_pass(wlr_output, &state, NULL, NULL); wlr_render_pass_add_rect(pass, &(struct wlr_render_rect_options){ .box = { .width = wlr_output->width, .height = wlr_output->height }, @@ -107,7 +108,8 @@ static void new_output_notify(struct wl_listener *listener, void *data) { struct wlr_output_mode *mode = wlr_output_preferred_mode(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_commit_state(sample_output->output, &state); wlr_output_state_finish(&state); -- cgit v1.2.3