aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Christoph Gysin <christoph.gysin@gmail.com>2015-11-29 14:51:42 +0200
committerLibravatar Christoph Gysin <christoph.gysin@gmail.com>2015-11-29 15:29:06 +0200
commit7d82cd9c0a418385fbde72f4503459ab7afa1bde (patch)
treed82e43a424ccde83f5ced21c79b2d6b519f62bd1 /sway
parentcmd_output: Cleanup cmd_output argument handling (diff)
downloadsway-7d82cd9c0a418385fbde72f4503459ab7afa1bde.tar.gz
sway-7d82cd9c0a418385fbde72f4503459ab7afa1bde.tar.zst
sway-7d82cd9c0a418385fbde72f4503459ab7afa1bde.zip
cmd_output: Use list_seq_find() to find matching config
Diffstat (limited to 'sway')
-rw-r--r--sway/commands.c12
-rw-r--r--sway/config.c8
2 files changed, 13 insertions, 7 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 1106f095..4eaa210f 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -804,14 +804,12 @@ static struct cmd_results *cmd_output(int argc, char **argv) {
804 } 804 }
805 } 805 }
806 806
807 for (i = 0; i < config->output_configs->length; ++i) { 807 i = list_seq_find(config->output_configs, output_name_cmp, name);
808 if (i >= 0) {
809 // replace existing config
808 struct output_config *oc = config->output_configs->items[i]; 810 struct output_config *oc = config->output_configs->items[i];
809 if (strcmp(oc->name, output->name) == 0) { 811 list_del(config->output_configs, i);
810 // replace existing config 812 free_output_config(oc);
811 list_del(config->output_configs, i);
812 free_output_config(oc);
813 break;
814 }
815 } 813 }
816 list_add(config->output_configs, output); 814 list_add(config->output_configs, output);
817 815
diff --git a/sway/config.c b/sway/config.c
index e9785aba..bb9142c0 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -261,6 +261,14 @@ bool read_config(FILE *file, bool is_active) {
261 return success; 261 return success;
262} 262}
263 263
264int output_name_cmp(const void *item, const void *data)
265{
266 const struct output_config *output = item;
267 const char *name = data;
268
269 return strcmp(output->name, name);
270}
271
264void apply_output_config(struct output_config *oc, swayc_t *output) { 272void apply_output_config(struct output_config *oc, swayc_t *output) {
265 if (oc && oc->width > 0 && oc->height > 0) { 273 if (oc && oc->width > 0 && oc->height > 0) {
266 output->width = oc->width; 274 output->width = oc->width;