backend-x11: implement set_dpms

set_dpms() is used for sleep/wakeup. output_repaint_timer_handler() resets the
repaint_status if called while Weston is sleeping. If the timer is still active,
it will trigger a call to weston_output_finish_frame() which then triggers an
assertion, because the repaint_status is not REPAINT_AWAITING_COMPLETION.
Stop the timer and reset the repaint_status in this case to avoid this.

Schedule a repaint for WESTON_DPMS_ON to ensure that the current state is
rendered.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
This commit is contained in:
Michael Olbrich 2025-05-15 09:05:53 +02:00 committed by Marius Vlad
parent afc19c2e94
commit 2a7b4f52e7

View file

@ -883,6 +883,19 @@ x11_output_init_shm(struct x11_backend *b, struct x11_output *output,
return 0;
}
static void
x11_set_dpms(struct weston_output *base, enum dpms_enum level)
{
struct x11_output *output = to_x11_output(base);
if (level == WESTON_DPMS_ON)
weston_output_schedule_repaint(base);
else if (output->base.repaint_status == REPAINT_AWAITING_COMPLETION) {
wl_event_source_timer_update(output->finish_frame_timer, 0);
weston_output_schedule_repaint_reset(base);
}
}
static int
x11_output_switch_mode(struct weston_output *base, struct weston_mode *mode)
{
@ -1167,7 +1180,7 @@ x11_output_enable(struct weston_output *base)
output->base.start_repaint_loop = x11_output_start_repaint_loop;
output->base.assign_planes = NULL;
output->base.set_backlight = NULL;
output->base.set_dpms = NULL;
output->base.set_dpms = x11_set_dpms;
output->base.switch_mode = x11_output_switch_mode;
loop = wl_display_get_event_loop(b->compositor->wl_display);