diff --git a/include/sway/criteria.h b/include/sway/criteria.h index dc8dcb986..299ad7ff3 100644 --- a/include/sway/criteria.h +++ b/include/sway/criteria.h @@ -14,6 +14,13 @@ enum criteria_type { CT_NO_FOCUS = 1 << 4, }; +enum criteria_tribool_value { + TRIBOOL_UNDEFINED = 0, + TRIBOOL_TRUE = 1, + TRIBOOL_FALSE = 2, +}; + + struct criteria { enum criteria_type type; char *raw; // entire criteria string (for logging) @@ -37,6 +44,7 @@ struct criteria { bool tiling; char urgent; // 'l' for latest or 'o' for oldest pcre *workspace; + enum criteria_tribool_value fullscreen; }; bool criteria_is_empty(struct criteria *criteria); diff --git a/sway/criteria.c b/sway/criteria.c index b25828514..d5e6708bc 100644 --- a/sway/criteria.c +++ b/sway/criteria.c @@ -32,7 +32,8 @@ bool criteria_is_empty(struct criteria *criteria) { && !criteria->floating && !criteria->tiling && !criteria->urgent - && !criteria->workspace; + && !criteria->workspace + && criteria->fullscreen == TRIBOOL_UNDEFINED; } void criteria_destroy(struct criteria *criteria) { @@ -218,6 +219,14 @@ static bool criteria_matches_view(struct criteria *criteria, } } + if (criteria->fullscreen != TRIBOOL_UNDEFINED) { + const bool want_fullscreen = criteria->fullscreen == TRIBOOL_TRUE; + const bool is_fullscreen = view->container->fullscreen_mode != FULLSCREEN_NONE; + if (want_fullscreen != is_fullscreen) { + return false; + } + } + return true; } @@ -324,6 +333,7 @@ enum criteria_token { T_TITLE, T_URGENT, T_WORKSPACE, + T_FULLSCREEN, T_INVALID, }; @@ -359,6 +369,8 @@ static enum criteria_token token_from_name(char *name) { return T_TILING; } else if (strcmp(name, "floating") == 0) { return T_FLOATING; + } else if (strcmp(name, "fullscreen") == 0) { + return T_FULLSCREEN; } return T_INVALID; } @@ -439,6 +451,7 @@ static char *get_focused_prop(enum criteria_token token, bool *autofail) { case T_FLOATING: case T_TILING: case T_URGENT: + case T_FULLSCREEN: case T_INVALID: *autofail = false; break; @@ -544,6 +557,16 @@ static bool parse_token(struct criteria *criteria, char *name, char *value) { case T_WORKSPACE: generate_regex(&criteria->workspace, effective_value); break; + case T_FULLSCREEN: + if (strcmp(effective_value, "true") == 0) { + criteria->fullscreen = TRIBOOL_TRUE; + } else if (strcmp(effective_value, "false") == 0) { + criteria->fullscreen = TRIBOOL_FALSE; + } else { + error = + strdup("The value for 'fullscreen' must be 'true' or 'false'"); + } + break; case T_INVALID: break; } diff --git a/sway/sway.5.scd b/sway/sway.5.scd index 280b6176b..d82ae6190 100644 --- a/sway/sway.5.scd +++ b/sway/sway.5.scd @@ -870,6 +870,9 @@ The following attributes may be matched with: expression. If the value is \_\_focused\_\_, then all the views on the currently focused workspace matches. +*fullscreen* + Compares the fullscreen mode of the window. Can be "true" or "false". + # SEE ALSO *sway*(1) *sway-input*(5) *sway-output*(5) *sway-bar*(5) *sway-ipc*(7)