aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2015-11-16 10:49:02 -0500
committerDrew DeVault <sir@cmpwn.com>2015-11-16 10:49:02 -0500
commit95c65ee33ea05963e334555311414e0d834de4b7 (patch)
tree8b4aa0be0fdfa0a18503671a1ce7220ae5b05d3f
parent00a4591b39182fe57c86e72f06f78fb61475f952 (diff)
parenta94a91a723d87b37d5e24e352f83a051144a3ecf (diff)
downloadsway-95c65ee33ea05963e334555311414e0d834de4b7.tar.xz
Merge pull request #232 from sce/replace_output_config
cmd_output: Replace existing config if called multiple times.
-rw-r--r--include/config.h1
-rw-r--r--sway/commands.c9
-rw-r--r--sway/config.c2
3 files changed, 11 insertions, 1 deletions
diff --git a/include/config.h b/include/config.h
index 8338033c..3cbe7ce0 100644
--- a/include/config.h
+++ b/include/config.h
@@ -98,6 +98,7 @@ char *do_var_replacement(char *str);
/** Sets up a WLC output handle based on a given output_config.
*/
void apply_output_config(struct output_config *oc, swayc_t *output);
+void free_output_config(struct output_config *oc);
/**
* Global config singleton.
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);
}