From 2445d279604d7be38c00db60ffde4279a3c75459 Mon Sep 17 00:00:00 2001 From: Calvin Lee Date: Sun, 2 Apr 2017 14:38:33 -0600 Subject: Impliment i3-style marks This commit adds three commands to sway: `show_marks`, `mark` and `unmark`. Marks are displayed right-aligned in the window border as i3 does. Marks may be found using criteria. Fixes #1007 --- sway/criteria.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'sway/criteria.c') 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 @@ enum criteria_type { // *must* keep in sync with criteria_strings[] CRIT_CLASS, + CRIT_CON_MARK, CRIT_ID, CRIT_INSTANCE, CRIT_TITLE, @@ -25,6 +26,7 @@ enum criteria_type { // *must* keep in sync with criteria_strings[] // this *must* match the ordering in criteria_type enum static const char * const criteria_strings[] = { "class", + "con_mark", "id", "instance", "title", @@ -243,6 +245,10 @@ ect_cleanup: return error; } +int regex_cmp(const char *item, const regex_t *regex) { + return regexec(regex, item, 0, NULL, 0); +} + // test a single view if it matches list of criteria tokens (all of them). static bool criteria_test(swayc_t *cont, list_t *tokens) { if (cont->type != C_VIEW) { @@ -264,6 +270,11 @@ static bool criteria_test(swayc_t *cont, list_t *tokens) { matches++; } break; + case CRIT_CON_MARK: + if (crit->regex && cont->marks && (list_seq_find(cont->marks, (int (*)(const void *, const void *))regex_cmp, crit->regex) != -1)) { + ++matches; + } + break; case CRIT_ID: if (!cont->app_id) { // ignore -- cgit v1.2.3