mirror of
https://github.com/gwenhael-le-moine/sway-patched-tray-menu.git
synced 2024-12-28 22:23:42 +01:00
criteria cleanup
This commit is contained in:
parent
6b03b1205d
commit
5505d84ac2
3 changed files with 12 additions and 7 deletions
|
@ -34,7 +34,7 @@ char *extract_crit_tokens(list_t *tokens, const char *criteria);
|
||||||
list_t *criteria_for(swayc_t *cont);
|
list_t *criteria_for(swayc_t *cont);
|
||||||
|
|
||||||
// Returns a list of all containers that match the given list of tokens.
|
// Returns a list of all containers that match the given list of tokens.
|
||||||
list_t *container_for(list_t *tokens);
|
list_t *container_for_crit_tokens(list_t *tokens);
|
||||||
|
|
||||||
// Returns true if any criteria in the given list matches this container
|
// Returns true if any criteria in the given list matches this container
|
||||||
bool criteria_any(swayc_t *cont, list_t *criteria);
|
bool criteria_any(swayc_t *cont, list_t *criteria);
|
||||||
|
|
|
@ -226,7 +226,7 @@ struct cmd_results *handle_command(char *_exec) {
|
||||||
free(tokens);
|
free(tokens);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
containers = container_for(tokens);
|
containers = container_for_crit_tokens(tokens);
|
||||||
|
|
||||||
free(tokens);
|
free(tokens);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -103,7 +103,8 @@ static int countchr(char *str, char c) {
|
||||||
// of buf.
|
// of buf.
|
||||||
//
|
//
|
||||||
// Returns error string or NULL if successful.
|
// Returns error string or NULL if successful.
|
||||||
static char *crit_tokens(int *argc, char ***buf, const char * const criteria_str) {
|
static char *crit_tokens(int *argc, char ***buf,
|
||||||
|
const char * const criteria_str) {
|
||||||
wlr_log(L_DEBUG, "Parsing criteria: '%s'", criteria_str);
|
wlr_log(L_DEBUG, "Parsing criteria: '%s'", criteria_str);
|
||||||
char *base = criteria_from(criteria_str);
|
char *base = criteria_from(criteria_str);
|
||||||
char *head = base;
|
char *head = base;
|
||||||
|
@ -423,16 +424,20 @@ struct list_tokens {
|
||||||
list_t *tokens;
|
list_t *tokens;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void container_match_add(swayc_t *container, struct list_tokens *list_tokens) {
|
static void container_match_add(swayc_t *container,
|
||||||
|
struct list_tokens *list_tokens) {
|
||||||
if (criteria_test(container, list_tokens->tokens)) {
|
if (criteria_test(container, list_tokens->tokens)) {
|
||||||
list_add(list_tokens->list, container);
|
list_add(list_tokens->list, container);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list_t *container_for(list_t *tokens) {
|
list_t *container_for_crit_tokens(list_t *tokens) {
|
||||||
struct list_tokens list_tokens = (struct list_tokens){create_list(), tokens};
|
struct list_tokens list_tokens =
|
||||||
|
(struct list_tokens){create_list(), tokens};
|
||||||
|
|
||||||
container_map(&root_container, (void (*)(swayc_t *, void *))container_match_add, &list_tokens);
|
container_map(&root_container,
|
||||||
|
(void (*)(swayc_t *, void *))container_match_add,
|
||||||
|
&list_tokens);
|
||||||
|
|
||||||
// TODO look in the scratchpad
|
// TODO look in the scratchpad
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue