diff options
author | S. Christoffer Eliesen <christoffer@eliesen.no> | 2015-11-16 11:40:24 +0100 |
---|---|---|
committer | S. Christoffer Eliesen <christoffer@eliesen.no> | 2015-11-16 15:57:42 +0100 |
commit | a94a91a723d87b37d5e24e352f83a051144a3ecf (patch) | |
tree | 8b4aa0be0fdfa0a18503671a1ce7220ae5b05d3f /sway | |
parent | Update README (diff) | |
download | sway-a94a91a723d87b37d5e24e352f83a051144a3ecf.tar.gz sway-a94a91a723d87b37d5e24e352f83a051144a3ecf.tar.zst sway-a94a91a723d87b37d5e24e352f83a051144a3ecf.zip |
cmd_output: Replace existing config if called multiple times.
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands.c | 9 | ||||
-rw-r--r-- | sway/config.c | 2 |
2 files changed, 10 insertions, 1 deletions
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) { | |||
733 | } | 733 | } |
734 | } | 734 | } |
735 | 735 | ||
736 | for (i = 0; i < config->output_configs->length; ++i) { | ||
737 | struct output_config *oc = config->output_configs->items[i]; | ||
738 | if (strcmp(oc->name, output->name) == 0) { | ||
739 | // replace existing config | ||
740 | list_del(config->output_configs, i); | ||
741 | free_output_config(oc); | ||
742 | break; | ||
743 | } | ||
744 | } | ||
736 | list_add(config->output_configs, output); | 745 | list_add(config->output_configs, output); |
737 | 746 | ||
738 | sway_log(L_DEBUG, "Config stored for output %s (%d x %d @ %d, %d)", | 747 | 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) { | |||
36 | free(mode); | 36 | free(mode); |
37 | } | 37 | } |
38 | 38 | ||
39 | static void free_output_config(struct output_config *oc) { | 39 | void free_output_config(struct output_config *oc) { |
40 | free(oc->name); | 40 | free(oc->name); |
41 | free(oc); | 41 | free(oc); |
42 | } | 42 | } |