From a94a91a723d87b37d5e24e352f83a051144a3ecf Mon Sep 17 00:00:00 2001 From: "S. Christoffer Eliesen" Date: Mon, 16 Nov 2015 11:40:24 +0100 Subject: cmd_output: Replace existing config if called multiple times. --- sway/commands.c | 9 +++++++++ sway/config.c | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'sway') diff --git a/sway/commands.c b/sway/commands.c index 2cfda07c..f194681e 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -733,6 +733,15 @@ static struct cmd_results *cmd_output(int argc, char **argv) { } } + for (i = 0; i < config->output_configs->length; ++i) { + struct output_config *oc = config->output_configs->items[i]; + if (strcmp(oc->name, output->name) == 0) { + // replace existing config + list_del(config->output_configs, i); + free_output_config(oc); + break; + } + } list_add(config->output_configs, output); sway_log(L_DEBUG, "Config stored for output %s (%d x %d @ %d, %d)", diff --git a/sway/config.c b/sway/config.c index 0b25ee60..ce6d8baf 100644 --- a/sway/config.c +++ b/sway/config.c @@ -36,7 +36,7 @@ static void free_mode(struct sway_mode *mode) { free(mode); } -static void free_output_config(struct output_config *oc) { +void free_output_config(struct output_config *oc) { free(oc->name); free(oc); } -- cgit v1.2.3