workspace criterion also applys to containers

This commit is contained in:
Bonsaiiv 2024-02-05 20:16:37 +01:00
parent f7a0f06dff
commit 4a664a2e7b
2 changed files with 26 additions and 22 deletions

View file

@ -159,6 +159,31 @@ static bool has_container_criteria(struct criteria *criteria) {
static bool criteria_matches_container(struct criteria *criteria,
struct sway_container *container) {
struct sway_seat *seat = input_manager_current_seat();
struct sway_container *focus = seat_get_focused_container(seat);
struct sway_view *focused = focus ? focus->view : NULL;
if (criteria->workspace) {
struct sway_workspace *ws = container->pending.workspace;
if (!ws) {
return false;
}
switch (criteria->workspace->match_type) {
case PATTERN_FOCUSED:
if (focused &&
strcmp(ws->name, focused->container->pending.workspace->name)) {
return false;
}
break;
case PATTERN_PCRE2:
if (regex_cmp(ws->name, criteria->workspace->regex) < 0) {
return false;
}
break;
}
}
if (criteria->con_mark) {
bool exists = false;
struct sway_container *con = container;
@ -358,27 +383,6 @@ static bool criteria_matches_view(struct criteria *criteria,
}
}
if (criteria->workspace) {
struct sway_workspace *ws = view->container->pending.workspace;
if (!ws) {
return false;
}
switch (criteria->workspace->match_type) {
case PATTERN_FOCUSED:
if (focused &&
strcmp(ws->name, focused->container->pending.workspace->name)) {
return false;
}
break;
case PATTERN_PCRE2:
if (regex_cmp(ws->name, criteria->workspace->regex) < 0) {
return false;
}
break;
}
}
if (criteria->pid) {
if (criteria->pid != view->pid) {
return false;

View file

@ -1031,7 +1031,7 @@ The following attributes may be matched with:
applications and requires XWayland.
*workspace*
Compare against the workspace name for this view. Can be a regular
Compare against the workspace name for this container. Can be a regular
expression. If the value is \_\_focused\_\_, then all the views on the
currently focused workspace matches.