mirror of
https://github.com/swaywm/sway.git
synced 2025-10-29 05:40:18 -04:00
Add xdg_toplevel tag to criteria
This commit is contained in:
parent
08142c3f3a
commit
cb33701f5e
3 changed files with 33 additions and 1 deletions
|
|
@ -56,6 +56,7 @@ struct criteria {
|
||||||
struct pattern *sandbox_engine;
|
struct pattern *sandbox_engine;
|
||||||
struct pattern *sandbox_app_id;
|
struct pattern *sandbox_app_id;
|
||||||
struct pattern *sandbox_instance_id;
|
struct pattern *sandbox_instance_id;
|
||||||
|
struct pattern *tag;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool criteria_is_empty(struct criteria *criteria);
|
bool criteria_is_empty(struct criteria *criteria);
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,8 @@ bool criteria_is_empty(struct criteria *criteria) {
|
||||||
&& !criteria->pid
|
&& !criteria->pid
|
||||||
&& !criteria->sandbox_engine
|
&& !criteria->sandbox_engine
|
||||||
&& !criteria->sandbox_app_id
|
&& !criteria->sandbox_app_id
|
||||||
&& !criteria->sandbox_instance_id;
|
&& !criteria->sandbox_instance_id
|
||||||
|
&& !criteria->tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The error pointer is used for parsing functions, and saves having to pass it
|
// The error pointer is used for parsing functions, and saves having to pass it
|
||||||
|
|
@ -104,6 +105,7 @@ void criteria_destroy(struct criteria *criteria) {
|
||||||
pattern_destroy(criteria->sandbox_engine);
|
pattern_destroy(criteria->sandbox_engine);
|
||||||
pattern_destroy(criteria->sandbox_app_id);
|
pattern_destroy(criteria->sandbox_app_id);
|
||||||
pattern_destroy(criteria->sandbox_instance_id);
|
pattern_destroy(criteria->sandbox_instance_id);
|
||||||
|
pattern_destroy(criteria->tag);
|
||||||
free(criteria->target);
|
free(criteria->target);
|
||||||
free(criteria->cmdlist);
|
free(criteria->cmdlist);
|
||||||
free(criteria->raw);
|
free(criteria->raw);
|
||||||
|
|
@ -314,6 +316,26 @@ static bool criteria_matches_view(struct criteria *criteria,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (criteria->tag) {
|
||||||
|
const char *tag = view_get_tag(view);
|
||||||
|
if (!tag) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (criteria->tag->match_type) {
|
||||||
|
case PATTERN_FOCUSED:
|
||||||
|
if (focused && lenient_strcmp(tag, view_get_tag(focused))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PATTERN_PCRE2:
|
||||||
|
if (regex_cmp(tag, criteria->tag->regex) < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!criteria_matches_container(criteria, view->container)) {
|
if (!criteria_matches_container(criteria, view->container)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -544,6 +566,7 @@ enum criteria_token {
|
||||||
T_SANDBOX_ENGINE,
|
T_SANDBOX_ENGINE,
|
||||||
T_SANDBOX_APP_ID,
|
T_SANDBOX_APP_ID,
|
||||||
T_SANDBOX_INSTANCE_ID,
|
T_SANDBOX_INSTANCE_ID,
|
||||||
|
T_TAG,
|
||||||
|
|
||||||
T_INVALID,
|
T_INVALID,
|
||||||
};
|
};
|
||||||
|
|
@ -589,6 +612,8 @@ static enum criteria_token token_from_name(char *name) {
|
||||||
return T_SANDBOX_APP_ID;
|
return T_SANDBOX_APP_ID;
|
||||||
} else if (strcmp(name, "sandbox_instance_id") == 0) {
|
} else if (strcmp(name, "sandbox_instance_id") == 0) {
|
||||||
return T_SANDBOX_INSTANCE_ID;
|
return T_SANDBOX_INSTANCE_ID;
|
||||||
|
} else if (strcmp(name, "tag") == 0) {
|
||||||
|
return T_TAG;
|
||||||
}
|
}
|
||||||
return T_INVALID;
|
return T_INVALID;
|
||||||
}
|
}
|
||||||
|
|
@ -700,6 +725,9 @@ static bool parse_token(struct criteria *criteria, char *name, char *value) {
|
||||||
case T_SANDBOX_INSTANCE_ID:
|
case T_SANDBOX_INSTANCE_ID:
|
||||||
pattern_create(&criteria->sandbox_instance_id, value);
|
pattern_create(&criteria->sandbox_instance_id, value);
|
||||||
break;
|
break;
|
||||||
|
case T_TAG:
|
||||||
|
pattern_create(&criteria->tag, value);
|
||||||
|
break;
|
||||||
case T_INVALID:
|
case T_INVALID:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1055,6 +1055,9 @@ The following attributes may be matched with:
|
||||||
Can be a regular expression. If value is \_\_focused\_\_, then the shell
|
Can be a regular expression. If value is \_\_focused\_\_, then the shell
|
||||||
must be the same as that of the currently focused window.
|
must be the same as that of the currently focused window.
|
||||||
|
|
||||||
|
*tag*
|
||||||
|
Compare value against the tag. _tag_ is specific to Wayland applications.
|
||||||
|
|
||||||
*tiling*
|
*tiling*
|
||||||
Matches tiling windows.
|
Matches tiling windows.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue