From e4bba906b68b9347c085a7833f6dbc7ddb1a41b4 Mon Sep 17 00:00:00 2001 From: Ashkan Kiani Date: Fri, 26 Jul 2019 12:30:04 -0700 Subject: Avoid adding duplicate criteria for no_focus and command --- sway/commands/for_window.c | 8 ++++++++ sway/commands/no_focus.c | 9 +++++++++ 2 files changed, 17 insertions(+) (limited to 'sway/commands') diff --git a/sway/commands/for_window.c b/sway/commands/for_window.c index 63cba099..ee9f4647 100644 --- a/sway/commands/for_window.c +++ b/sway/commands/for_window.c @@ -22,6 +22,14 @@ struct cmd_results *cmd_for_window(int argc, char **argv) { criteria->type = CT_COMMAND; criteria->cmdlist = join_args(argv + 1, argc - 1); + // Check if it already exists + if (criteria_already_exists(criteria)) { + sway_log(SWAY_DEBUG, "for_window already exists: '%s' -> '%s'", + criteria->raw, criteria->cmdlist); + criteria_destroy(criteria); + return cmd_results_new(CMD_SUCCESS, NULL); + } + list_add(config->criteria, criteria); sway_log(SWAY_DEBUG, "for_window: '%s' -> '%s' added", criteria->raw, criteria->cmdlist); diff --git a/sway/commands/no_focus.c b/sway/commands/no_focus.c index 07e824a1..2001e04f 100644 --- a/sway/commands/no_focus.c +++ b/sway/commands/no_focus.c @@ -18,7 +18,16 @@ struct cmd_results *cmd_no_focus(int argc, char **argv) { return error; } + criteria->type = CT_NO_FOCUS; + + // Check if it already exists + if (criteria_already_exists(criteria)) { + sway_log(SWAY_DEBUG, "no_focus already exists: '%s'", criteria->raw); + criteria_destroy(criteria); + return cmd_results_new(CMD_SUCCESS, NULL); + } + list_add(config->criteria, criteria); return cmd_results_new(CMD_SUCCESS, NULL); -- cgit v1.2.3