diff options
Diffstat (limited to 'sway/criteria.c')
-rw-r--r-- | sway/criteria.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/sway/criteria.c b/sway/criteria.c index bc0523ce..3ffc48f0 100644 --- a/sway/criteria.c +++ b/sway/criteria.c | |||
@@ -12,6 +12,7 @@ | |||
12 | 12 | ||
13 | enum criteria_type { // *must* keep in sync with criteria_strings[] | 13 | enum criteria_type { // *must* keep in sync with criteria_strings[] |
14 | CRIT_CLASS, | 14 | CRIT_CLASS, |
15 | CRIT_CON_MARK, | ||
15 | CRIT_ID, | 16 | CRIT_ID, |
16 | CRIT_INSTANCE, | 17 | CRIT_INSTANCE, |
17 | CRIT_TITLE, | 18 | CRIT_TITLE, |
@@ -25,6 +26,7 @@ enum criteria_type { // *must* keep in sync with criteria_strings[] | |||
25 | // this *must* match the ordering in criteria_type enum | 26 | // this *must* match the ordering in criteria_type enum |
26 | static const char * const criteria_strings[] = { | 27 | static const char * const criteria_strings[] = { |
27 | "class", | 28 | "class", |
29 | "con_mark", | ||
28 | "id", | 30 | "id", |
29 | "instance", | 31 | "instance", |
30 | "title", | 32 | "title", |
@@ -243,6 +245,10 @@ ect_cleanup: | |||
243 | return error; | 245 | return error; |
244 | } | 246 | } |
245 | 247 | ||
248 | int regex_cmp(const char *item, const regex_t *regex) { | ||
249 | return regexec(regex, item, 0, NULL, 0); | ||
250 | } | ||
251 | |||
246 | // test a single view if it matches list of criteria tokens (all of them). | 252 | // test a single view if it matches list of criteria tokens (all of them). |
247 | static bool criteria_test(swayc_t *cont, list_t *tokens) { | 253 | static bool criteria_test(swayc_t *cont, list_t *tokens) { |
248 | if (cont->type != C_VIEW) { | 254 | if (cont->type != C_VIEW) { |
@@ -264,6 +270,11 @@ static bool criteria_test(swayc_t *cont, list_t *tokens) { | |||
264 | matches++; | 270 | matches++; |
265 | } | 271 | } |
266 | break; | 272 | break; |
273 | case CRIT_CON_MARK: | ||
274 | if (crit->regex && cont->marks && (list_seq_find(cont->marks, (int (*)(const void *, const void *))regex_cmp, crit->regex) != -1)) { | ||
275 | ++matches; | ||
276 | } | ||
277 | break; | ||
267 | case CRIT_ID: | 278 | case CRIT_ID: |
268 | if (!cont->app_id) { | 279 | if (!cont->app_id) { |
269 | // ignore | 280 | // ignore |