aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/criteria.h2
-rw-r--r--sway/commands.c2
-rw-r--r--sway/criteria.c15
3 files changed, 12 insertions, 7 deletions
diff --git a/include/sway/criteria.h b/include/sway/criteria.h
index c5ed9857..9b4b4bef 100644
--- a/include/sway/criteria.h
+++ b/include/sway/criteria.h
@@ -34,7 +34,7 @@ char *extract_crit_tokens(list_t *tokens, const char *criteria);
34list_t *criteria_for(swayc_t *cont); 34list_t *criteria_for(swayc_t *cont);
35 35
36// Returns a list of all containers that match the given list of tokens. 36// Returns a list of all containers that match the given list of tokens.
37list_t *container_for(list_t *tokens); 37list_t *container_for_crit_tokens(list_t *tokens);
38 38
39// Returns true if any criteria in the given list matches this container 39// Returns true if any criteria in the given list matches this container
40bool criteria_any(swayc_t *cont, list_t *criteria); 40bool criteria_any(swayc_t *cont, list_t *criteria);
diff --git a/sway/commands.c b/sway/commands.c
index 3ab5add6..a77ff791 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -226,7 +226,7 @@ struct cmd_results *handle_command(char *_exec) {
226 free(tokens); 226 free(tokens);
227 goto cleanup; 227 goto cleanup;
228 } 228 }
229 containers = container_for(tokens); 229 containers = container_for_crit_tokens(tokens);
230 230
231 free(tokens); 231 free(tokens);
232 } else { 232 } else {
diff --git a/sway/criteria.c b/sway/criteria.c
index 09733616..2eee331c 100644
--- a/sway/criteria.c
+++ b/sway/criteria.c
@@ -103,7 +103,8 @@ static int countchr(char *str, char c) {
103// of buf. 103// of buf.
104// 104//
105// Returns error string or NULL if successful. 105// Returns error string or NULL if successful.
106static char *crit_tokens(int *argc, char ***buf, const char * const criteria_str) { 106static char *crit_tokens(int *argc, char ***buf,
107 const char * const criteria_str) {
107 wlr_log(L_DEBUG, "Parsing criteria: '%s'", criteria_str); 108 wlr_log(L_DEBUG, "Parsing criteria: '%s'", criteria_str);
108 char *base = criteria_from(criteria_str); 109 char *base = criteria_from(criteria_str);
109 char *head = base; 110 char *head = base;
@@ -423,16 +424,20 @@ struct list_tokens {
423 list_t *tokens; 424 list_t *tokens;
424}; 425};
425 426
426static void container_match_add(swayc_t *container, struct list_tokens *list_tokens) { 427static void container_match_add(swayc_t *container,
428 struct list_tokens *list_tokens) {
427 if (criteria_test(container, list_tokens->tokens)) { 429 if (criteria_test(container, list_tokens->tokens)) {
428 list_add(list_tokens->list, container); 430 list_add(list_tokens->list, container);
429 } 431 }
430} 432}
431 433
432list_t *container_for(list_t *tokens) { 434list_t *container_for_crit_tokens(list_t *tokens) {
433 struct list_tokens list_tokens = (struct list_tokens){create_list(), tokens}; 435 struct list_tokens list_tokens =
436 (struct list_tokens){create_list(), tokens};
434 437
435 container_map(&root_container, (void (*)(swayc_t *, void *))container_match_add, &list_tokens); 438 container_map(&root_container,
439 (void (*)(swayc_t *, void *))container_match_add,
440 &list_tokens);
436 441
437 // TODO look in the scratchpad 442 // TODO look in the scratchpad
438 443