From ee5f98ad49fed0439f3313ec685307831d1d1d05 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 18 Jul 2019 21:38:12 +0300 Subject: output: atomic mode, enabled, scale and transform This commit makes more output properties (mode, enabled, scale and transform) atomic. This means that they are double-buffered and only applied on commit. Compositors now need to call wlr_output_commit after setting any of those properties. Internally, backends still apply properties sequentially. The behaviour should be exactly the same as before. Future commits will update some backends to take advantage of the atomic interface. Some backends are non-atomic by design, e.g. the X11 backend or the legacy DRM backend. Updates: https://github.com/swaywm/wlroots/issues/1640 --- backend/headless/output.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'backend/headless') diff --git a/backend/headless/output.c b/backend/headless/output.c index 992a4883..1916b525 100644 --- a/backend/headless/output.c +++ b/backend/headless/output.c @@ -58,8 +58,26 @@ static bool output_attach_render(struct wlr_output *wlr_output, } static bool output_commit(struct wlr_output *wlr_output) { - // Nothing needs to be done for pbuffers - wlr_output_send_present(wlr_output, NULL); + if (wlr_output->pending.committed & WLR_OUTPUT_STATE_ENABLED) { + wlr_log(WLR_DEBUG, "Cannot disable a headless output"); + return false; + } + + if (wlr_output->pending.committed & WLR_OUTPUT_STATE_MODE) { + assert(wlr_output->pending.mode_type == WLR_OUTPUT_STATE_MODE_CUSTOM); + if (!output_set_custom_mode(wlr_output, + wlr_output->pending.custom_mode.width, + wlr_output->pending.custom_mode.height, + wlr_output->pending.custom_mode.refresh)) { + return false; + } + } + + if (wlr_output->pending.committed & WLR_OUTPUT_STATE_BUFFER) { + // Nothing needs to be done for pbuffers + wlr_output_send_present(wlr_output, NULL); + } + return true; } @@ -76,7 +94,6 @@ static void output_destroy(struct wlr_output *wlr_output) { } static const struct wlr_output_impl output_impl = { - .set_custom_mode = output_set_custom_mode, .destroy = output_destroy, .attach_render = output_attach_render, .commit = output_commit, -- cgit v1.2.3