query: added "monitor" option

This commit is contained in:
Orfeas 2024-10-27 19:43:39 +02:00
parent 9181ea1e6f
commit 66373a5fdd
3 changed files with 15 additions and 5 deletions

View file

@ -301,6 +301,7 @@ struct view_query {
char *tiled_region;
char *desktop;
enum ssd_mode decoration;
char *monitor;
};
struct xdg_toplevel_view {

View file

@ -495,6 +495,8 @@ fill_action_query(char *nodename, char *content, struct action *action)
current_view_query->desktop = xstrdup(content);
} else if (!strcasecmp(nodename, "decoration")) {
current_view_query->decoration = ssd_mode_parse(content);
} else if (!strcasecmp(nodename, "monitor")) {
current_view_query->monitor = xstrdup(content);
}
}

View file

@ -86,6 +86,7 @@ view_query_free(struct view_query *query)
zfree(query->sandbox_app_id);
zfree(query->tiled_region);
zfree(query->desktop);
zfree(query->monitor);
zfree(query);
}
@ -195,7 +196,7 @@ view_matches_query(struct view *view, struct view_query *query)
}
if (query->tiled != VIEW_EDGE_INVALID) {
match = (query->tiled == view->tiled) ? LAB_STATE_ENABLED : LAB_STATE_DISABLED;
match = bool_to_tristate(query->tiled == view->tiled);
wlr_log(WLR_DEBUG, "tiled: %d\n", match);
if (match == LAB_STATE_DISABLED) {
return false;
@ -203,10 +204,8 @@ view_matches_query(struct view *view, struct view_query *query)
}
if (query->tiled_region) {
match = (view->tiled_region &&
!strcasecmp(query->tiled_region, view->tiled_region->name))
? LAB_STATE_ENABLED
: LAB_STATE_DISABLED;
match = bool_to_tristate(view->tiled_region &&
!strcasecmp(query->tiled_region, view->tiled_region->name));
wlr_log(WLR_DEBUG, "tiled_region: %d\n", match);
if (match == LAB_STATE_DISABLED) {
return false;
@ -238,6 +237,14 @@ view_matches_query(struct view *view, struct view_query *query)
}
}
if (query->monitor) {
struct output *target = output_from_name(view->server, query->monitor);
match = bool_to_tristate(target == view->output);
if (match == LAB_STATE_DISABLED) {
return false;
}
}
return match == LAB_STATE_ENABLED;
}