diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-01-18 20:50:30 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-18 20:50:30 -0500 |
commit | fa19960d1e700c9999117c9bd4b1ad0fbc16a028 (patch) | |
tree | 99225cbb7e76e869ba96ce87bbf28ca47f299fa2 /sway/criteria.c | |
parent | dd41ce45f7eb26ad84e9b3fe7a83f200f6396711 (diff) | |
parent | d443bce6fe78fc21560afe2d194f8bbd7593820d (diff) |
Merge pull request #1052 from Hummer12007/instance
Add window instance support
Diffstat (limited to 'sway/criteria.c')
-rw-r--r-- | sway/criteria.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/sway/criteria.c b/sway/criteria.c index 739a183e..fd1ea64b 100644 --- a/sway/criteria.c +++ b/sway/criteria.c @@ -173,9 +173,8 @@ static char *parse_criteria_name(enum criteria_type *type, char *name) { char *error = malloc(len); snprintf(error, len, fmt, name); return error; - } else if (*type == CRIT_INSTANCE || *type == CRIT_URGENT || - *type == CRIT_WINDOW_ROLE || *type == CRIT_WINDOW_TYPE) { - + } else if (*type == CRIT_URGENT || *type == CRIT_WINDOW_ROLE || + *type == CRIT_WINDOW_TYPE) { // (we're just being helpful here) const char *fmt = "\"%s\" criteria currently unsupported, " "no window will match this"; @@ -267,6 +266,16 @@ static bool criteria_test(swayc_t *cont, list_t *tokens) { } break; case CRIT_INSTANCE: + if (!cont->instance) { + // ignore + } else if (strcmp(crit->raw, "focused") == 0) { + swayc_t *focused = get_focused_view(&root_container); + if (focused->instance && strcmp(cont->instance, focused->instance) == 0) { + matches++; + } + } else if (crit->regex && regexec(crit->regex, cont->instance, 0, NULL, 0) == 0) { + matches++; + } break; case CRIT_TITLE: if (!cont->name) { |