diff options
author | Kenny Levinsen <kl@kl.wtf> | 2024-03-16 00:57:11 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2024-03-28 10:45:20 +0100 |
commit | 923f642b704022442cc3245a2fa13278341c14e0 (patch) | |
tree | 31e18e0dbbc78f5d4e2f2c2f2f49c81e02fe9543 | |
parent | config/output: Introduce apply_output_configs (diff) | |
download | sway-923f642b704022442cc3245a2fa13278341c14e0.tar.gz sway-923f642b704022442cc3245a2fa13278341c14e0.tar.zst sway-923f642b704022442cc3245a2fa13278341c14e0.zip |
output/config: Add apply_all_output_configs
Apply all output configs as they are. This differs from
apply_output_config_to_outputs, which tries to apply a specific output
config.
-rw-r--r-- | include/sway/config.h | 2 | ||||
-rw-r--r-- | sway/config/output.c | 28 |
2 files changed, 30 insertions, 0 deletions
diff --git a/include/sway/config.h b/include/sway/config.h index d23fe578..eff7cfbb 100644 --- a/include/sway/config.h +++ b/include/sway/config.h | |||
@@ -695,6 +695,8 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output); | |||
695 | bool apply_output_configs(struct matched_output_config *configs, | 695 | bool apply_output_configs(struct matched_output_config *configs, |
696 | size_t configs_len, bool test_only); | 696 | size_t configs_len, bool test_only); |
697 | 697 | ||
698 | void apply_all_output_configs(void); | ||
699 | |||
698 | bool test_output_config(struct output_config *oc, struct sway_output *output); | 700 | bool test_output_config(struct output_config *oc, struct sway_output *output); |
699 | 701 | ||
700 | struct output_config *store_output_config(struct output_config *oc); | 702 | struct output_config *store_output_config(struct output_config *oc); |
diff --git a/sway/config/output.c b/sway/config/output.c index de9515e2..5bf5bed5 100644 --- a/sway/config/output.c +++ b/sway/config/output.c | |||
@@ -809,6 +809,34 @@ out: | |||
809 | return ok; | 809 | return ok; |
810 | } | 810 | } |
811 | 811 | ||
812 | void apply_all_output_configs(void) { | ||
813 | size_t configs_len = wl_list_length(&root->all_outputs); | ||
814 | struct matched_output_config *configs = calloc(configs_len, sizeof(*configs)); | ||
815 | if (!configs) { | ||
816 | return; | ||
817 | } | ||
818 | |||
819 | int config_idx = 0; | ||
820 | struct sway_output *sway_output; | ||
821 | wl_list_for_each(sway_output, &root->all_outputs, link) { | ||
822 | if (sway_output == root->fallback_output) { | ||
823 | configs_len--; | ||
824 | continue; | ||
825 | } | ||
826 | |||
827 | struct matched_output_config *config = &configs[config_idx++]; | ||
828 | config->output = sway_output; | ||
829 | config->config = find_output_config(sway_output); | ||
830 | } | ||
831 | |||
832 | apply_output_configs(configs, configs_len, false); | ||
833 | for (size_t idx = 0; idx < configs_len; idx++) { | ||
834 | struct matched_output_config *cfg = &configs[idx]; | ||
835 | free_output_config(cfg->config); | ||
836 | } | ||
837 | free(configs); | ||
838 | } | ||
839 | |||
812 | void apply_output_config_to_outputs(struct output_config *oc) { | 840 | void apply_output_config_to_outputs(struct output_config *oc) { |
813 | size_t configs_len = wl_list_length(&root->all_outputs); | 841 | size_t configs_len = wl_list_length(&root->all_outputs); |
814 | struct matched_output_config *configs = calloc(configs_len, sizeof(*configs)); | 842 | struct matched_output_config *configs = calloc(configs_len, sizeof(*configs)); |