From d952ce403e63a1d91f07b72d971500d583609223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Sk=C3=B6ld?= Date: Fri, 1 Sep 2023 21:28:09 -0700 Subject: [PATCH] i3 compat: Adding support for the `all` criteria Matches all views. i3 PR: https://github.com/i3/i3/pull/4460 Fixes #7110 --- include/sway/criteria.h | 1 + sway/criteria.c | 13 ++++++++++--- sway/sway.5.scd | 3 +++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/sway/criteria.h b/include/sway/criteria.h index 59f57f94f..8da345ea6 100644 --- a/include/sway/criteria.h +++ b/include/sway/criteria.h @@ -43,6 +43,7 @@ struct criteria { struct pattern *window_role; enum atom_name window_type; #endif + bool all; bool floating; bool tiling; char urgent; // 'l' for latest or 'o' for oldest diff --git a/sway/criteria.c b/sway/criteria.c index d7326beac..78ea8b8a4 100644 --- a/sway/criteria.c +++ b/sway/criteria.c @@ -19,6 +19,7 @@ bool criteria_is_empty(struct criteria *criteria) { return !criteria->title && !criteria->shell + && !criteria->all && !criteria->app_id && !criteria->con_mark && !criteria->con_id @@ -456,6 +457,7 @@ static enum atom_name parse_window_type(const char *type) { #endif enum criteria_token { + T_ALL, T_APP_ID, T_CON_ID, T_CON_MARK, @@ -478,7 +480,9 @@ enum criteria_token { }; static enum criteria_token token_from_name(char *name) { - if (strcmp(name, "app_id") == 0) { + if (strcmp(name, "all") == 0) { + return T_ALL; + } else if (strcmp(name, "app_id") == 0) { return T_APP_ID; } else if (strcmp(name, "con_id") == 0) { return T_CON_ID; @@ -524,8 +528,8 @@ static bool parse_token(struct criteria *criteria, char *name, char *value) { return false; } - // Require value, unless token is floating or tiled - if (!value && token != T_FLOATING && token != T_TILING) { + // Require value, unless token is all, floating or tiled + if (!value && token != T_ALL && token != T_FLOATING && token != T_TILING) { const char *fmt = "Token '%s' requires a value"; int len = strlen(fmt) + strlen(name) - 1; error = malloc(len); @@ -535,6 +539,9 @@ static bool parse_token(struct criteria *criteria, char *name, char *value) { char *endptr = NULL; switch (token) { + case T_ALL: + criteria->all = true; + break; case T_TITLE: pattern_create(&criteria->title, value); break; diff --git a/sway/sway.5.scd b/sway/sway.5.scd index 78d7d2316..f064ad52f 100644 --- a/sway/sway.5.scd +++ b/sway/sway.5.scd @@ -962,6 +962,9 @@ properties in practice for your applications. The following attributes may be matched with: +*all* + Matches all windows. + *app_id* Compare value against the app id. Can be a regular expression. If value is \_\_focused\_\_, then the app id must be the same as that of the currently