mirror of
https://github.com/swaywm/sway.git
synced 2024-11-21 23:41:27 +00:00
config/output: Update output position in two passes
The modeset logic iterates over all outputs at the end, sets their new position in the layout and takes a copy of its geometry that is later referenced by layout and scene management code. If one output is auto configured, then a later output that is manually configured can lead to the first output being moved without the stored geometry being updated. Split this into two passes: The first pass finalizes the output config and makes updates to the layout, while the second pass updates the copy of the geometry and arranges things as a result of it.
This commit is contained in:
parent
4cfcb3643b
commit
78fa4e9856
|
@ -533,14 +533,6 @@ static bool finalize_output_config(struct output_config *oc, struct sway_output
|
||||||
wlr_output_layout_add_auto(root->output_layout, wlr_output);
|
wlr_output_layout_add_auto(root->output_layout, wlr_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update output->{lx, ly, width, height}
|
|
||||||
struct wlr_box output_box;
|
|
||||||
wlr_output_layout_get_box(root->output_layout, wlr_output, &output_box);
|
|
||||||
output->lx = output_box.x;
|
|
||||||
output->ly = output_box.y;
|
|
||||||
output->width = output_box.width;
|
|
||||||
output->height = output_box.height;
|
|
||||||
|
|
||||||
if (!output->enabled) {
|
if (!output->enabled) {
|
||||||
output_enable(output);
|
output_enable(output);
|
||||||
}
|
}
|
||||||
|
@ -562,6 +554,15 @@ static bool finalize_output_config(struct output_config *oc, struct sway_output
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void output_update_position(struct sway_output *output) {
|
||||||
|
struct wlr_box output_box;
|
||||||
|
wlr_output_layout_get_box(root->output_layout, output->wlr_output, &output_box);
|
||||||
|
output->lx = output_box.x;
|
||||||
|
output->ly = output_box.y;
|
||||||
|
output->width = output_box.width;
|
||||||
|
output->height = output_box.height;
|
||||||
|
}
|
||||||
|
|
||||||
// find_output_config_from_list returns a merged output_config containing all
|
// find_output_config_from_list returns a merged output_config containing all
|
||||||
// stored configuration that applies to the specified output.
|
// stored configuration that applies to the specified output.
|
||||||
static struct output_config *find_output_config_from_list(
|
static struct output_config *find_output_config_from_list(
|
||||||
|
@ -933,6 +934,13 @@ static bool apply_resolved_output_configs(struct matched_output_config *configs,
|
||||||
sway_log(SWAY_DEBUG, "Finalizing config for %s",
|
sway_log(SWAY_DEBUG, "Finalizing config for %s",
|
||||||
cfg->output->wlr_output->name);
|
cfg->output->wlr_output->name);
|
||||||
finalize_output_config(cfg->config, cfg->output);
|
finalize_output_config(cfg->config, cfg->output);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output layout being applied in finalize_output_config can shift outputs
|
||||||
|
// around, so we do a second pass to update positions and arrange.
|
||||||
|
for (size_t idx = 0; idx < configs_len; idx++) {
|
||||||
|
struct matched_output_config *cfg = &configs[idx];
|
||||||
|
output_update_position(cfg->output);
|
||||||
arrange_layers(cfg->output);
|
arrange_layers(cfg->output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue