criteria: change workspace to support regex

This changes the workspace criteria to support regex instead of basic
strings. This matches i3's behavior.
master
Brian Ashworth 6 years ago committed by Drew DeVault
parent 3330faded5
commit 52a61671e9

@ -35,7 +35,7 @@ struct criteria {
bool floating; bool floating;
bool tiling; bool tiling;
char urgent; // 'l' for latest or 'o' for oldest char urgent; // 'l' for latest or 'o' for oldest
char *workspace; pcre *workspace;
}; };
bool criteria_is_empty(struct criteria *criteria); bool criteria_is_empty(struct criteria *criteria);

@ -208,7 +208,7 @@ static bool criteria_matches_view(struct criteria *criteria,
if (criteria->workspace) { if (criteria->workspace) {
struct sway_workspace *ws = view->container->workspace; struct sway_workspace *ws = view->container->workspace;
if (!ws || strcmp(ws->name, criteria->workspace) != 0) { if (!ws || regex_cmp(ws->name, criteria->workspace) != 0) {
return false; return false;
} }
} }
@ -515,7 +515,7 @@ static bool parse_token(struct criteria *criteria, char *name, char *value) {
} }
break; break;
case T_WORKSPACE: case T_WORKSPACE:
criteria->workspace = strdup(effective_value); generate_regex(&criteria->workspace, effective_value);
break; break;
case T_INVALID: case T_INVALID:
break; break;

Loading…
Cancel
Save