From 7d82cd9c0a418385fbde72f4503459ab7afa1bde Mon Sep 17 00:00:00 2001 From: Christoph Gysin Date: Sun, 29 Nov 2015 14:51:42 +0200 Subject: cmd_output: Use list_seq_find() to find matching config --- sway/config.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sway/config.c') 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) { return success; } +int output_name_cmp(const void *item, const void *data) +{ + const struct output_config *output = item; + const char *name = data; + + return strcmp(output->name, name); +} + void apply_output_config(struct output_config *oc, swayc_t *output) { if (oc && oc->width > 0 && oc->height > 0) { output->width = oc->width; -- cgit v1.2.3 From ffdfaaa985467ea673c9c388bf1a18f7ca83af41 Mon Sep 17 00:00:00 2001 From: Christoph Gysin Date: Sun, 29 Nov 2015 15:24:11 +0200 Subject: apply_output_config: use list_seq_find() to find config --- sway/config.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'sway/config.c') diff --git a/sway/config.c b/sway/config.c index bb9142c0..dd466e5b 100644 --- a/sway/config.c +++ b/sway/config.c @@ -299,12 +299,10 @@ void apply_output_config(struct output_config *oc, swayc_t *output) { if (!oc || !oc->background) { // Look for a * config for background - int i; - for (i = 0; i < config->output_configs->length; ++i) { + int i = list_seq_find(config->output_configs, output_name_cmp, "*"); + if (i >= 0) { oc = config->output_configs->items[i]; - if (strcasecmp("*", oc->name) == 0) { - break; - } + } else { oc = NULL; } } -- cgit v1.2.3