From dd1a8f01dd0b96d0c3bddb1bb1b32028c72d10a4 Mon Sep 17 00:00:00 2001 From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Sun, 29 Jan 2023 09:58:42 +0100 Subject: [PATCH] src/output.c: only overwrite the automatic layout if necessary The wlroots wlr_output_layout provides two different modes of operation: - automatically - manually In automatic mode wlroots reacts to new / removed outputs and resolution changes and then adjusts the output positions within the layout itself. The manual mode disables this behavior and thus it is the whole responsibility of the caller (e.g. us relaying whatever wdisplays / kanshi provides) to ensure that the layout is somewhat sane. E.g. that it doesn't have any holes between outputs and there are no overlapping outputs. The mode is set for each output individually. To use (and keep using) the automatic mode, outputs have to be added via the _add_auto() variant (which we do) and they are not allowed to be moved via _move() (which we currently do and thus break the automatic layout). To fix that, this patch compares the user (tool) supplied position to the automatically calculated position and only if they differ we call _move(). --- src/output.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/output.c b/src/output.c index 3b6482a8..05808afe 100644 --- a/src/output.c +++ b/src/output.c @@ -314,8 +314,13 @@ output_config_apply(struct server *server, } if (output_enabled) { - wlr_output_layout_move(server->output_layout, o, - head->state.x, head->state.y); + struct wlr_box pos = {0}; + wlr_output_layout_get_box(server->output_layout, o, &pos); + if (pos.x != head->state.x || pos.y != head->state.y) { + /* This overrides the automatic layout */ + wlr_output_layout_move(server->output_layout, o, + head->state.x, head->state.y); + } } if (need_to_remove) {