diff --git a/sway/criteria.c b/sway/criteria.c index 78ea8b8a..484378c2 100644 --- a/sway/criteria.c +++ b/sway/criteria.c @@ -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; diff --git a/sway/sway.5.scd b/sway/sway.5.scd index 7e58b528..7146db84 100644 --- a/sway/sway.5.scd +++ b/sway/sway.5.scd @@ -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.