aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Johan Sköld <git@johan.skold.cc>2023-09-01 21:28:09 -0700
committerLibravatar Simon Ser <contact@emersion.fr>2023-09-07 10:42:54 +0900
commitd952ce403e63a1d91f07b72d971500d583609223 (patch)
tree21782cf134499ebc3d4fffd41c50a582adb55990
parentcommands/input/map_from_region: don't treat 0x prefix as hex identifier (diff)
downloadsway-d952ce403e63a1d91f07b72d971500d583609223.tar.gz
sway-d952ce403e63a1d91f07b72d971500d583609223.tar.zst
sway-d952ce403e63a1d91f07b72d971500d583609223.zip
i3 compat: Adding support for the `all` criteria
Matches all views. i3 PR: https://github.com/i3/i3/pull/4460 Fixes #7110
-rw-r--r--include/sway/criteria.h1
-rw-r--r--sway/criteria.c13
-rw-r--r--sway/sway.5.scd3
3 files changed, 14 insertions, 3 deletions
diff --git a/include/sway/criteria.h b/include/sway/criteria.h
index 59f57f94..8da345ea 100644
--- a/include/sway/criteria.h
+++ b/include/sway/criteria.h
@@ -43,6 +43,7 @@ struct criteria {
43 struct pattern *window_role; 43 struct pattern *window_role;
44 enum atom_name window_type; 44 enum atom_name window_type;
45#endif 45#endif
46 bool all;
46 bool floating; 47 bool floating;
47 bool tiling; 48 bool tiling;
48 char urgent; // 'l' for latest or 'o' for oldest 49 char urgent; // 'l' for latest or 'o' for oldest
diff --git a/sway/criteria.c b/sway/criteria.c
index d7326bea..78ea8b8a 100644
--- a/sway/criteria.c
+++ b/sway/criteria.c
@@ -19,6 +19,7 @@
19bool criteria_is_empty(struct criteria *criteria) { 19bool criteria_is_empty(struct criteria *criteria) {
20 return !criteria->title 20 return !criteria->title
21 && !criteria->shell 21 && !criteria->shell
22 && !criteria->all
22 && !criteria->app_id 23 && !criteria->app_id
23 && !criteria->con_mark 24 && !criteria->con_mark
24 && !criteria->con_id 25 && !criteria->con_id
@@ -456,6 +457,7 @@ static enum atom_name parse_window_type(const char *type) {
456#endif 457#endif
457 458
458enum criteria_token { 459enum criteria_token {
460 T_ALL,
459 T_APP_ID, 461 T_APP_ID,
460 T_CON_ID, 462 T_CON_ID,
461 T_CON_MARK, 463 T_CON_MARK,
@@ -478,7 +480,9 @@ enum criteria_token {
478}; 480};
479 481
480static enum criteria_token token_from_name(char *name) { 482static enum criteria_token token_from_name(char *name) {
481 if (strcmp(name, "app_id") == 0) { 483 if (strcmp(name, "all") == 0) {
484 return T_ALL;
485 } else if (strcmp(name, "app_id") == 0) {
482 return T_APP_ID; 486 return T_APP_ID;
483 } else if (strcmp(name, "con_id") == 0) { 487 } else if (strcmp(name, "con_id") == 0) {
484 return T_CON_ID; 488 return T_CON_ID;
@@ -524,8 +528,8 @@ static bool parse_token(struct criteria *criteria, char *name, char *value) {
524 return false; 528 return false;
525 } 529 }
526 530
527 // Require value, unless token is floating or tiled 531 // Require value, unless token is all, floating or tiled
528 if (!value && token != T_FLOATING && token != T_TILING) { 532 if (!value && token != T_ALL && token != T_FLOATING && token != T_TILING) {
529 const char *fmt = "Token '%s' requires a value"; 533 const char *fmt = "Token '%s' requires a value";
530 int len = strlen(fmt) + strlen(name) - 1; 534 int len = strlen(fmt) + strlen(name) - 1;
531 error = malloc(len); 535 error = malloc(len);
@@ -535,6 +539,9 @@ static bool parse_token(struct criteria *criteria, char *name, char *value) {
535 539
536 char *endptr = NULL; 540 char *endptr = NULL;
537 switch (token) { 541 switch (token) {
542 case T_ALL:
543 criteria->all = true;
544 break;
538 case T_TITLE: 545 case T_TITLE:
539 pattern_create(&criteria->title, value); 546 pattern_create(&criteria->title, value);
540 break; 547 break;
diff --git a/sway/sway.5.scd b/sway/sway.5.scd
index 78d7d231..f064ad52 100644
--- a/sway/sway.5.scd
+++ b/sway/sway.5.scd
@@ -962,6 +962,9 @@ properties in practice for your applications.
962 962
963The following attributes may be matched with: 963The following attributes may be matched with:
964 964
965*all*
966 Matches all windows.
967
965*app_id* 968*app_id*
966 Compare value against the app id. Can be a regular expression. If value is 969 Compare value against the app id. Can be a regular expression. If value is
967 \_\_focused\_\_, then the app id must be the same as that of the currently 970 \_\_focused\_\_, then the app id must be the same as that of the currently