diff options
author | Simon Ser <contact@emersion.fr> | 2023-06-22 15:48:35 +0200 |
---|---|---|
committer | Alexander Orzechowski <alex@ozal.ski> | 2023-06-23 18:07:26 +0000 |
commit | be050979684ae8779a56e4b0166cfb21d1935d35 (patch) | |
tree | c4a77ff1363875abb59508b3b3a5cdff28dbb895 /examples | |
parent | 8a5b5e6f28dae650df36a271213655b8bdf52dbf (diff) |
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.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/fullscreen-shell.c | 6 | ||||
-rw-r--r-- | examples/output-layers.c | 6 | ||||
-rw-r--r-- | examples/output-layout.c | 6 | ||||
-rw-r--r-- | examples/pointer.c | 6 | ||||
-rw-r--r-- | examples/rotation.c | 6 | ||||
-rw-r--r-- | examples/scene-graph.c | 3 | ||||
-rw-r--r-- | examples/simple.c | 6 | ||||
-rw-r--r-- | examples/tablet.c | 6 | ||||
-rw-r--r-- | examples/touch.c | 6 |
9 files changed, 34 insertions, 17 deletions
diff --git a/examples/fullscreen-shell.c b/examples/fullscreen-shell.c index 9800a4c2..22053493 100644 --- a/examples/fullscreen-shell.c +++ b/examples/fullscreen-shell.c @@ -89,7 +89,8 @@ static void output_handle_frame(struct wl_listener *listener, void *data) { int width, height; wlr_output_effective_resolution(output->wlr_output, &width, &height); - 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(output->wlr_output, &state, NULL, NULL); if (pass == NULL) { @@ -166,7 +167,8 @@ static void server_handle_new_output(struct wl_listener *listener, void *data) { 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_commit_state(wlr_output, &state); wlr_output_state_finish(&state); diff --git a/examples/output-layers.c b/examples/output-layers.c index e6ec8150..092394f5 100644 --- a/examples/output-layers.c +++ b/examples/output-layers.c @@ -82,7 +82,8 @@ static void output_handle_frame(struct wl_listener *listener, void *data) { }; } - struct wlr_output_state output_state = {0}; + struct wlr_output_state output_state; + wlr_output_state_init(&output_state); wlr_output_state_set_layers(&output_state, layers_arr.data, layers_arr.size / sizeof(struct wlr_output_layer_state)); @@ -175,7 +176,8 @@ static void server_handle_new_output(struct wl_listener *listener, void *data) { 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_commit_state(wlr_output, &state); wlr_output_state_finish(&state); diff --git a/examples/output-layout.c b/examples/output-layout.c index ee45c9c2..1cd7d6e9 100644 --- a/examples/output-layout.c +++ b/examples/output-layout.c @@ -114,7 +114,8 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { struct sample_state *sample = output->sample; struct wlr_output *wlr_output = output->output; - struct wlr_output_state output_state = {0}; + struct wlr_output_state output_state; + wlr_output_state_init(&output_state); struct wlr_render_pass *pass = wlr_output_begin_render_pass(wlr_output, &output_state, NULL, NULL); wlr_render_pass_add_rect(pass, &(struct wlr_render_rect_options){ @@ -178,7 +179,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(output, &state); wlr_output_state_finish(&state); diff --git a/examples/pointer.c b/examples/pointer.c index c67ce1ca..127b77f3 100644 --- a/examples/pointer.c +++ b/examples/pointer.c @@ -101,7 +101,8 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { struct wlr_renderer *renderer = state->renderer; assert(renderer); - struct wlr_output_state output_state = {0}; + struct wlr_output_state output_state; + wlr_output_state_init(&output_state); struct wlr_render_pass *pass = wlr_output_begin_render_pass(wlr_output, &output_state, NULL, NULL); wlr_render_pass_add_rect(pass, &(struct wlr_render_rect_options){ .box = { .width = wlr_output->width, .height = wlr_output->height }, @@ -280,7 +281,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(output, &state); wlr_output_state_finish(&state); diff --git a/examples/rotation.c b/examples/rotation.c index c7bd85ae..2770529f 100644 --- a/examples/rotation.c +++ b/examples/rotation.c @@ -59,7 +59,8 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { int32_t width, height; wlr_output_effective_resolution(wlr_output, &width, &height); - struct wlr_output_state output_state = {0}; + struct wlr_output_state output_state; + wlr_output_state_init(&output_state); struct wlr_render_pass *pass = wlr_output_begin_render_pass(wlr_output, &output_state, NULL, NULL); wlr_render_pass_add_rect(pass, &(struct wlr_render_rect_options){ @@ -122,7 +123,8 @@ static void new_output_notify(struct wl_listener *listener, void *data) { sample_output->x_offs = sample_output->y_offs = 0; sample_output->x_vel = sample_output->y_vel = 128; - struct wlr_output_state state = {0}; + struct wlr_output_state state; + wlr_output_state_init(&state); wlr_output_state_set_transform(&state, sample->transform); sample_output->output = output; diff --git a/examples/scene-graph.c b/examples/scene-graph.c index 68441c11..0ea61c28 100644 --- a/examples/scene-graph.c +++ b/examples/scene-graph.c @@ -83,7 +83,8 @@ static void server_handle_new_output(struct wl_listener *listener, void *data) { 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_commit_state(wlr_output, &state); wlr_output_state_finish(&state); 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); diff --git a/examples/tablet.c b/examples/tablet.c index ee6712b1..7ac81549 100644 --- a/examples/tablet.c +++ b/examples/tablet.c @@ -87,7 +87,8 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { int32_t width, height; wlr_output_effective_resolution(wlr_output, &width, &height); - struct wlr_output_state output_state = {0}; + struct wlr_output_state output_state; + wlr_output_state_init(&output_state); struct wlr_render_pass *pass = wlr_output_begin_render_pass(wlr_output, &output_state, NULL, NULL); wlr_render_pass_add_rect(pass, &(struct wlr_render_rect_options){ @@ -285,7 +286,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(output, &state); wlr_output_state_finish(&state); diff --git a/examples/touch.c b/examples/touch.c index ab2e80ce..c054fea9 100644 --- a/examples/touch.c +++ b/examples/touch.c @@ -76,7 +76,8 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { int32_t width, height; wlr_output_effective_resolution(wlr_output, &width, &height); - struct wlr_output_state output_state = {0}; + struct wlr_output_state output_state; + wlr_output_state_init(&output_state); struct wlr_render_pass *pass = wlr_output_begin_render_pass(wlr_output, &output_state, NULL, NULL); wlr_render_pass_add_rect(pass, &(struct wlr_render_rect_options){ .box = { .width = width, .height = height }, @@ -184,7 +185,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(output, &state); wlr_output_state_finish(&state); |