Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workspace criterion also applies to containers #7955

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 25 additions & 21 deletions sway/criteria.c
Expand Up @@ -158,6 +158,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;
Expand Down Expand Up @@ -357,27 +382,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;
Expand Down
2 changes: 1 addition & 1 deletion sway/sway.5.scd
Expand Up @@ -1037,7 +1037,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.

Expand Down