From 48e8c158eae726be1c1027404021cfd97f9aaed4 Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Mon, 13 Jun 2022 15:38:13 +0200 Subject: [PATCH] compositor: only reflow the outputs if the shell did not move them weston_compositor_reflow_outputs() assumes that all output are positioned from left to right with no gaps in the same order in which they where created. If the shell moves an output with weston_output_move() then this assumption is no longer true. So stop reflowing the outputs in the case. The shell is now responsible for positioning all outputs as needed. Signed-off-by: Michael Olbrich --- include/libweston/libweston.h | 1 + libweston/compositor.c | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index dbf80b15..6e5ebbca 100644 --- a/include/libweston/libweston.h +++ b/include/libweston/libweston.h @@ -1263,6 +1263,7 @@ struct weston_compositor { struct wl_list plugin_api_list; /* struct weston_plugin_api::link */ uint32_t output_id_pool; + bool output_flow_dirty; struct xkb_rule_names xkb_names; struct xkb_context *xkb_context; diff --git a/libweston/compositor.c b/libweston/compositor.c index 5448e8ac..6282901a 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -6253,6 +6253,9 @@ weston_head_get_destroy_listener(struct weston_head *head, return wl_signal_get(&head->destroy_signal, notify); } +static void +weston_output_set_position(struct weston_output *output, int x, int y); + /* Move other outputs when one is resized so the space remains contiguous. */ static void weston_compositor_reflow_outputs(struct weston_compositor *compositor, @@ -6261,6 +6264,9 @@ weston_compositor_reflow_outputs(struct weston_compositor *compositor, struct weston_output *output; bool start_resizing = false; + if (compositor->output_flow_dirty) + return; + if (!delta_width) return; @@ -6271,7 +6277,7 @@ weston_compositor_reflow_outputs(struct weston_compositor *compositor, } if (start_resizing) { - weston_output_move(output, output->x + delta_width, output->y); + weston_output_set_position(output, output->x + delta_width, output->y); output->dirty = 1; } } @@ -6377,8 +6383,8 @@ weston_output_init_geometry(struct weston_output *output, int x, int y) /** * \ingroup output */ -WL_EXPORT void -weston_output_move(struct weston_output *output, int x, int y) +static void +weston_output_set_position(struct weston_output *output, int x, int y) { struct weston_head *head; struct wl_resource *resource; @@ -6424,6 +6430,16 @@ weston_output_move(struct weston_output *output, int x, int y) } } +/** + * \ingroup output + */ +WL_EXPORT void +weston_output_move(struct weston_output *output, int x, int y) +{ + output->compositor->output_flow_dirty = true; + weston_output_set_position(output, x, y); +} + /** Signal that a pending output is taken into use. * * Removes the output from the pending list and adds it to the compositor's