|
|
@ -247,62 +247,62 @@ static bool criteria_test(swayc_t *cont, list_t *tokens) {
|
|
|
|
for (int i = 0; i < tokens->length; i++) {
|
|
|
|
for (int i = 0; i < tokens->length; i++) {
|
|
|
|
struct crit_token *crit = tokens->items[i];
|
|
|
|
struct crit_token *crit = tokens->items[i];
|
|
|
|
switch (crit->type) {
|
|
|
|
switch (crit->type) {
|
|
|
|
case CRIT_CLASS:
|
|
|
|
case CRIT_CLASS:
|
|
|
|
if (!cont->class) {
|
|
|
|
if (!cont->class) {
|
|
|
|
// ignore
|
|
|
|
// ignore
|
|
|
|
} else if (strcmp(crit->raw, "focused") == 0) {
|
|
|
|
} else if (strcmp(crit->raw, "focused") == 0) {
|
|
|
|
swayc_t *focused = get_focused_view(&root_container);
|
|
|
|
swayc_t *focused = get_focused_view(&root_container);
|
|
|
|
if (focused->class && strcmp(cont->class, focused->class) == 0) {
|
|
|
|
if (focused->class && strcmp(cont->class, focused->class) == 0) {
|
|
|
|
matches++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (crit->regex && regexec(crit->regex, cont->class, 0, NULL, 0) == 0) {
|
|
|
|
|
|
|
|
matches++;
|
|
|
|
matches++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
} else if (crit->regex && regexec(crit->regex, cont->class, 0, NULL, 0) == 0) {
|
|
|
|
case CRIT_ID:
|
|
|
|
matches++;
|
|
|
|
if (!cont->app_id) {
|
|
|
|
}
|
|
|
|
// ignore
|
|
|
|
break;
|
|
|
|
} else if (crit->regex && regexec(crit->regex, cont->app_id, 0, NULL, 0) == 0) {
|
|
|
|
case CRIT_ID:
|
|
|
|
matches++;
|
|
|
|
if (!cont->app_id) {
|
|
|
|
}
|
|
|
|
// ignore
|
|
|
|
break;
|
|
|
|
} else if (crit->regex && regexec(crit->regex, cont->app_id, 0, NULL, 0) == 0) {
|
|
|
|
case CRIT_INSTANCE:
|
|
|
|
matches++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CRIT_TITLE:
|
|
|
|
break;
|
|
|
|
if (!cont->name) {
|
|
|
|
case CRIT_INSTANCE:
|
|
|
|
// ignore
|
|
|
|
break;
|
|
|
|
} else if (strcmp(crit->raw, "focused") == 0) {
|
|
|
|
case CRIT_TITLE:
|
|
|
|
swayc_t *focused = get_focused_view(&root_container);
|
|
|
|
if (!cont->name) {
|
|
|
|
if (focused->name && strcmp(cont->name, focused->name) == 0) {
|
|
|
|
// ignore
|
|
|
|
matches++;
|
|
|
|
} else if (strcmp(crit->raw, "focused") == 0) {
|
|
|
|
}
|
|
|
|
swayc_t *focused = get_focused_view(&root_container);
|
|
|
|
} else if (crit->regex && regexec(crit->regex, cont->name, 0, NULL, 0) == 0) {
|
|
|
|
if (focused->name && strcmp(cont->name, focused->name) == 0) {
|
|
|
|
matches++;
|
|
|
|
matches++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
} else if (crit->regex && regexec(crit->regex, cont->name, 0, NULL, 0) == 0) {
|
|
|
|
case CRIT_URGENT: // "latest" or "oldest"
|
|
|
|
matches++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CRIT_WINDOW_ROLE:
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case CRIT_URGENT: // "latest" or "oldest"
|
|
|
|
case CRIT_WINDOW_TYPE:
|
|
|
|
break;
|
|
|
|
// TODO wlc indeed exposes this information
|
|
|
|
case CRIT_WINDOW_ROLE:
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case CRIT_WORKSPACE: ;
|
|
|
|
case CRIT_WINDOW_TYPE:
|
|
|
|
swayc_t *cont_ws = swayc_parent_by_type(cont, C_WORKSPACE);
|
|
|
|
// TODO wlc indeed exposes this information
|
|
|
|
if (!cont_ws || !cont_ws->name) {
|
|
|
|
break;
|
|
|
|
// ignore
|
|
|
|
case CRIT_WORKSPACE: ;
|
|
|
|
} else if (strcmp(crit->raw, "focused") == 0) {
|
|
|
|
swayc_t *cont_ws = swayc_parent_by_type(cont, C_WORKSPACE);
|
|
|
|
swayc_t *focused_ws = swayc_active_workspace();
|
|
|
|
if (!cont_ws || !cont_ws->name) {
|
|
|
|
if (focused_ws->name && strcmp(cont_ws->name, focused_ws->name) == 0) {
|
|
|
|
// ignore
|
|
|
|
matches++;
|
|
|
|
} else if (strcmp(crit->raw, "focused") == 0) {
|
|
|
|
}
|
|
|
|
swayc_t *focused_ws = swayc_active_workspace();
|
|
|
|
} else if (crit->regex && regexec(crit->regex, cont_ws->name, 0, NULL, 0) == 0) {
|
|
|
|
if (focused_ws->name && strcmp(cont_ws->name, focused_ws->name) == 0) {
|
|
|
|
matches++;
|
|
|
|
matches++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
} else if (crit->regex && regexec(crit->regex, cont_ws->name, 0, NULL, 0) == 0) {
|
|
|
|
default:
|
|
|
|
matches++;
|
|
|
|
sway_abort("Invalid criteria type (%i)", crit->type);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
sway_abort("Invalid criteria type (%i)", crit->type);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return matches == tokens->length;
|
|
|
|
return matches == tokens->length;
|
|
|
|