frontend: Expand simple head function

In order to allow passing additional pre/post callbacks. This allows
further re-use of the simple_head_enable() function instead of
creating a similar dedicated function. We can then re-use the same
function for enabling remote outputs.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This commit is contained in:
Marius Vlad 2024-06-26 19:41:50 +03:00 committed by Derek Foreman
parent 14cfb97949
commit 3842c1c737
2 changed files with 14 additions and 3 deletions

View File

@ -1869,7 +1869,9 @@ weston_output_lazy_align(struct weston_output *output)
static void static void
simple_head_enable(struct wet_compositor *wet, struct wet_backend *wb, simple_head_enable(struct wet_compositor *wet, struct wet_backend *wb,
struct weston_head *head) struct weston_head *head, struct weston_head *head_to_mirror,
wet_head_additional_setup wet_head_pre_enable,
wet_head_additional_setup wet_head_post_enable)
{ {
struct weston_output *output; struct weston_output *output;
int ret = 0; int ret = 0;
@ -1884,7 +1886,10 @@ simple_head_enable(struct wet_compositor *wet, struct wet_backend *wb,
return; return;
} }
weston_output_lazy_align(output); if (wet_head_pre_enable && head_to_mirror)
wet_head_pre_enable(head, head_to_mirror);
else
weston_output_lazy_align(output);
if (wb->simple_output_configure) if (wb->simple_output_configure)
ret = wb->simple_output_configure(output); ret = wb->simple_output_configure(output);
@ -1906,6 +1911,9 @@ simple_head_enable(struct wet_compositor *wet, struct wet_backend *wb,
return; return;
} }
if (wet_head_post_enable && head)
wet_head_post_enable(head, head_to_mirror);
wet_head_tracker_create(wet, head); wet_head_tracker_create(wet, head);
/* The weston_compositor will track and destroy the output on exit. */ /* The weston_compositor will track and destroy the output on exit. */
@ -1958,7 +1966,7 @@ simple_heads_changed(struct wl_listener *listener, void *arg)
non_desktop = weston_head_is_non_desktop(head); non_desktop = weston_head_is_non_desktop(head);
if (connected && !enabled && !non_desktop) { if (connected && !enabled && !non_desktop) {
simple_head_enable(wet, wb, head); simple_head_enable(wet, wb, head, NULL, NULL, NULL);
} else if (!connected && enabled) { } else if (!connected && enabled) {
simple_head_disable(head); simple_head_disable(head);
} else if (enabled && changed) { } else if (enabled && changed) {

View File

@ -50,3 +50,6 @@ int
wet_output_set_colorimetry_mode(struct weston_output *output, wet_output_set_colorimetry_mode(struct weston_output *output,
struct weston_config_section *section, struct weston_config_section *section,
bool have_color_manager); bool have_color_manager);
typedef void (*wet_head_additional_setup)(struct weston_head *head,
struct weston_head *head_to_mirror);