aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
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) {
}
}
- for (i = 0; i < config->output_configs->length; ++i) {
+ i = list_seq_find(config->output_configs, output_name_cmp, name);
+ if (i >= 0) {
+ // replace existing config
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_del(config->output_configs, i);
+ free_output_config(oc);
}
list_add(config->output_configs, output);
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;