From 65f27b2fbc87399ca444e5b94bbe73efdc1c0201 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Wed, 12 Jan 2022 12:08:36 +1100 Subject: [PATCH] sway_mirror: allow output configuration changes during mirror session --- sway/config/output.c | 42 +++++++++++++++++++----------------------- sway/desktop/mirror.c | 9 ++------- 2 files changed, 21 insertions(+), 30 deletions(-) diff --git a/sway/config/output.c b/sway/config/output.c index 8dfb8b505..543a061b1 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -483,13 +483,6 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) { return false; } - // block changes to active mirror dsts; these will be applied during reclaim_output - if (mirror_output_is_mirror_dst(output)) { - sway_log(SWAY_DEBUG, "Not configuring mirror dst output %s", - output->wlr_output->name); - return false; - } - struct wlr_output *wlr_output = output->wlr_output; // Flag to prevent the output mode event handler from calling us @@ -545,24 +538,27 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) { } } - // Find position for it - if (oc && (oc->x != -1 || oc->y != -1)) { - sway_log(SWAY_DEBUG, "Set %s position to %d, %d", oc->name, oc->x, oc->y); - wlr_output_layout_add(root->output_layout, wlr_output, oc->x, oc->y); - } else { - wlr_output_layout_add_auto(root->output_layout, wlr_output); - } + if (!mirror_output_is_mirror_dst(output)) { - // Update output->{lx, ly, width, height} - struct wlr_box *output_box = - wlr_output_layout_get_box(root->output_layout, wlr_output); - output->lx = output_box->x; - output->ly = output_box->y; - output->width = output_box->width; - output->height = output_box->height; + // Find position for it + if (oc && (oc->x != -1 || oc->y != -1)) { + sway_log(SWAY_DEBUG, "Set %s position to %d, %d", oc->name, oc->x, oc->y); + wlr_output_layout_add(root->output_layout, wlr_output, oc->x, oc->y); + } else { + wlr_output_layout_add_auto(root->output_layout, wlr_output); + } - if (!output->enabled) { - output_enable(output); + // Update output->{lx, ly, width, height} + struct wlr_box *output_box = + wlr_output_layout_get_box(root->output_layout, wlr_output); + output->lx = output_box->x; + output->ly = output_box->y; + output->width = output_box->width; + output->height = output_box->height; + + if (!output->enabled) { + output_enable(output); + } } if (oc && oc->max_render_time >= 0) { diff --git a/sway/desktop/mirror.c b/sway/desktop/mirror.c index 8402f9257..02bd55761 100644 --- a/sway/desktop/mirror.c +++ b/sway/desktop/mirror.c @@ -34,9 +34,7 @@ static struct wlr_output *container_output(struct sway_container *container) { void vacate_output(struct sway_output *output) { // arranges root - if (output->enabled) { - output_disable(output); - } + output_disable(output); // idempotent wlr_output_layout_remove(root->output_layout, output->wlr_output); @@ -44,15 +42,12 @@ void vacate_output(struct sway_output *output) { /** * Reclaim an output, arranging root as though it is a newly enabled output. - * - * Any "pending" changes that were blocked in apply_output_config during the - * mirror session will be applied. */ void reclaim_output(struct sway_output *output) { struct output_config *oc = find_output_config(output); - // calls output_enable + // calls wlr_output_layout_add, output_enable apply_output_config(oc, output); free_output_config(oc);