mirror of
https://github.com/swaywm/sway.git
synced 2024-11-26 18:01:29 +00:00
parent
0c4b7907a0
commit
484cc189e9
|
@ -18,6 +18,7 @@ struct criteria {
|
||||||
char *target; // workspace or output name for `assign` criteria
|
char *target; // workspace or output name for `assign` criteria
|
||||||
|
|
||||||
pcre *title;
|
pcre *title;
|
||||||
|
pcre *shell;
|
||||||
pcre *app_id;
|
pcre *app_id;
|
||||||
pcre *class;
|
pcre *class;
|
||||||
pcre *instance;
|
pcre *instance;
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
bool criteria_is_empty(struct criteria *criteria) {
|
bool criteria_is_empty(struct criteria *criteria) {
|
||||||
return !criteria->title
|
return !criteria->title
|
||||||
|
&& !criteria->shell
|
||||||
&& !criteria->app_id
|
&& !criteria->app_id
|
||||||
&& !criteria->class
|
&& !criteria->class
|
||||||
&& !criteria->instance
|
&& !criteria->instance
|
||||||
|
@ -29,6 +30,7 @@ bool criteria_is_empty(struct criteria *criteria) {
|
||||||
|
|
||||||
void criteria_destroy(struct criteria *criteria) {
|
void criteria_destroy(struct criteria *criteria) {
|
||||||
pcre_free(criteria->title);
|
pcre_free(criteria->title);
|
||||||
|
pcre_free(criteria->shell);
|
||||||
pcre_free(criteria->app_id);
|
pcre_free(criteria->app_id);
|
||||||
pcre_free(criteria->class);
|
pcre_free(criteria->class);
|
||||||
pcre_free(criteria->instance);
|
pcre_free(criteria->instance);
|
||||||
|
@ -53,6 +55,13 @@ static bool criteria_matches_view(struct criteria *criteria,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (criteria->shell) {
|
||||||
|
const char *shell = view_get_type(view);
|
||||||
|
if (!shell || regex_cmp(shell, criteria->shell) != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (criteria->app_id) {
|
if (criteria->app_id) {
|
||||||
const char *app_id = view_get_app_id(view);
|
const char *app_id = view_get_app_id(view);
|
||||||
if (!app_id || regex_cmp(app_id, criteria->app_id) != 0) {
|
if (!app_id || regex_cmp(app_id, criteria->app_id) != 0) {
|
||||||
|
@ -206,6 +215,7 @@ enum criteria_token {
|
||||||
T_FLOATING,
|
T_FLOATING,
|
||||||
T_ID,
|
T_ID,
|
||||||
T_INSTANCE,
|
T_INSTANCE,
|
||||||
|
T_SHELL,
|
||||||
T_TILING,
|
T_TILING,
|
||||||
T_TITLE,
|
T_TITLE,
|
||||||
T_URGENT,
|
T_URGENT,
|
||||||
|
@ -229,6 +239,8 @@ static enum criteria_token token_from_name(char *name) {
|
||||||
return T_ID;
|
return T_ID;
|
||||||
} else if (strcmp(name, "instance") == 0) {
|
} else if (strcmp(name, "instance") == 0) {
|
||||||
return T_INSTANCE;
|
return T_INSTANCE;
|
||||||
|
} else if (strcmp(name, "shell") == 0) {
|
||||||
|
return T_SHELL;
|
||||||
} else if (strcmp(name, "title") == 0) {
|
} else if (strcmp(name, "title") == 0) {
|
||||||
return T_TITLE;
|
return T_TITLE;
|
||||||
} else if (strcmp(name, "urgent") == 0) {
|
} else if (strcmp(name, "urgent") == 0) {
|
||||||
|
@ -271,6 +283,9 @@ static char *get_focused_prop(enum criteria_token token) {
|
||||||
case T_INSTANCE:
|
case T_INSTANCE:
|
||||||
value = view_get_instance(view);
|
value = view_get_instance(view);
|
||||||
break;
|
break;
|
||||||
|
case T_SHELL:
|
||||||
|
value = view_get_type(view);
|
||||||
|
break;
|
||||||
case T_TITLE:
|
case T_TITLE:
|
||||||
value = view_get_class(view);
|
value = view_get_class(view);
|
||||||
break;
|
break;
|
||||||
|
@ -332,6 +347,9 @@ static bool parse_token(struct criteria *criteria, char *name, char *value) {
|
||||||
case T_TITLE:
|
case T_TITLE:
|
||||||
generate_regex(&criteria->title, effective_value);
|
generate_regex(&criteria->title, effective_value);
|
||||||
break;
|
break;
|
||||||
|
case T_SHELL:
|
||||||
|
generate_regex(&criteria->shell, effective_value);
|
||||||
|
break;
|
||||||
case T_APP_ID:
|
case T_APP_ID:
|
||||||
generate_regex(&criteria->app_id, effective_value);
|
generate_regex(&criteria->app_id, effective_value);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -551,6 +551,11 @@ The following attributes may be matched with:
|
||||||
value is \_\_focused\_\_, then the window instance must be the same as that
|
value is \_\_focused\_\_, then the window instance must be the same as that
|
||||||
of the currently focused window.
|
of the currently focused window.
|
||||||
|
|
||||||
|
*shell*
|
||||||
|
Compare value against the window shell, such as "xdg\_shell" or "xwayland".
|
||||||
|
Can be a regular expression. If value is \_\_focused\_\_, then the shell
|
||||||
|
must be the same as that of the currently focused window.
|
||||||
|
|
||||||
*tiling*
|
*tiling*
|
||||||
Matches tiling windows.
|
Matches tiling windows.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue