From 9becff0ba56ac7da8b1235aa5740fb04414636a2 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Sat, 16 Mar 2024 01:11:35 +0100 Subject: [PATCH] output/config: Remove reset_outputs and co. apply_output_config_to_outputs uses the specified output config to check which outputs to apply to, and to use as backup when no config is found. If any config matches the output, the specified config will be disregarded. The only remaining user of apply_output_config_to_outputs is reset_outputs, which called apply_output_config_to_outputs with either the first stored wildcard config, or a new empty wildcard config. Providing a stored or empty wildcard config is practically the same as calling `apply_all_output_configs`. Replace uses of `reset_outputs` with `apply_all_output_configs` and remove the now unused functions. --- include/sway/config.h | 4 ---- sway/config.c | 2 +- sway/config/output.c | 53 ------------------------------------------- 3 files changed, 1 insertion(+), 58 deletions(-) diff --git a/include/sway/config.h b/include/sway/config.h index 69b14446..7e67ba21 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -701,10 +701,6 @@ struct output_config *store_output_config(struct output_config *oc); struct output_config *find_output_config(struct sway_output *output); -void apply_output_config_to_outputs(struct output_config *oc); - -void reset_outputs(void); - void free_output_config(struct output_config *oc); bool spawn_swaybg(void); diff --git a/sway/config.c b/sway/config.c index 72fc41e7..f9131e0f 100644 --- a/sway/config.c +++ b/sway/config.c @@ -532,7 +532,7 @@ bool load_main_config(const char *file, bool is_active, bool validating) { } sway_switch_retrigger_bindings_for_all(); - reset_outputs(); + apply_all_output_configs(); spawn_swaybg(); config->reloading = false; diff --git a/sway/config/output.c b/sway/config/output.c index cb12683d..a7c2f9b8 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -807,59 +807,6 @@ void apply_all_output_configs(void) { free(configs); } -void apply_output_config_to_outputs(struct output_config *oc) { - size_t configs_len = wl_list_length(&root->all_outputs); - struct matched_output_config *configs = calloc(configs_len, sizeof(*configs)); - if (!configs) { - return; - } - - // Try to find the output container and apply configuration now. If - // this is during startup then there will be no container and config - // will be applied during normal "new output" event from wlroots. - int config_idx = 0; - struct sway_output *sway_output; - wl_list_for_each(sway_output, &root->all_outputs, link) { - if (sway_output == root->fallback_output) { - configs_len--; - continue; - } - - struct matched_output_config *config = &configs[config_idx++]; - config->output = sway_output; - config->config = find_output_config(sway_output); - - if (!output_match_name_or_id(sway_output, oc->name)) { - continue; - } - - if (!config->config && oc) { - // No stored output config matched, apply oc directly - sway_log(SWAY_DEBUG, "Applying oc directly"); - config->config = new_output_config(oc->name); - merge_output_config(config->config, oc); - } - } - - apply_output_configs(configs, configs_len, false); - for (size_t idx = 0; idx < configs_len; idx++) { - struct matched_output_config *cfg = &configs[idx]; - free_output_config(cfg->config); - } - free(configs); -} - -void reset_outputs(void) { - struct output_config *oc = NULL; - int i = list_seq_find(config->output_configs, output_name_cmp, "*"); - if (i >= 0) { - oc = config->output_configs->items[i]; - } else { - oc = store_output_config(new_output_config("*")); - } - apply_output_config_to_outputs(oc); -} - void free_output_config(struct output_config *oc) { if (!oc) { return;