]> git.mdlowis.com Git - proto/labwc.git/commitdiff
src/output.c: only overwrite the automatic layout if necessary
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Sun, 29 Jan 2023 08:58:42 +0000 (09:58 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sun, 29 Jan 2023 14:36:15 +0000 (14:36 +0000)
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

index 3b6482a8d69e07d4bcff530f2a7fd8b220dcdca7..05808afef448be2463ee49c1d889cc7c718f49ce 100644 (file)
@@ -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) {