From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Sun, 29 Jan 2023 08:58:42 +0000 (+0100) Subject: src/output.c: only overwrite the automatic layout if necessary X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=dd1a8f01dd0b96d0c3bddb1bb1b32028c72d10a4;p=proto%2Flabwc.git 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(). --- 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) {