query: eliminate query.maximized tristates

This commit is contained in:
Orfeas 2024-10-30 19:47:59 +02:00
parent 9247236938
commit ac2d1b4177
4 changed files with 13 additions and 53 deletions

View file

@ -53,6 +53,7 @@ enum three_state {
* Therefore when parsing rc.xml, "None" means "Invalid". * Therefore when parsing rc.xml, "None" means "Invalid".
*/ */
enum view_axis { enum view_axis {
VIEW_AXIS_INVALID = -1,
VIEW_AXIS_NONE = 0, VIEW_AXIS_NONE = 0,
VIEW_AXIS_HORIZONTAL = (1 << 0), VIEW_AXIS_HORIZONTAL = (1 << 0),
VIEW_AXIS_VERTICAL = (1 << 1), VIEW_AXIS_VERTICAL = (1 << 1),
@ -291,9 +292,7 @@ struct view_query {
char *sandbox_engine; char *sandbox_engine;
char *sandbox_app_id; char *sandbox_app_id;
enum three_state shaded; enum three_state shaded;
enum three_state maximized_full; enum view_axis maximized;
enum three_state maximized_vertical;
enum three_state maximized_horizontal;
enum three_state iconified; enum three_state iconified;
enum three_state focused; enum three_state focused;
enum three_state omnipresent; enum three_state omnipresent;

View file

@ -366,7 +366,7 @@ action_arg_from_xml_node(struct action *action, const char *nodename, const char
case ACTION_TYPE_UNMAXIMIZE: case ACTION_TYPE_UNMAXIMIZE:
if (!strcmp(argument, "direction")) { if (!strcmp(argument, "direction")) {
enum view_axis axis = view_axis_parse(content); enum view_axis axis = view_axis_parse(content);
if (axis == VIEW_AXIS_NONE) { if (axis == VIEW_AXIS_NONE || axis == VIEW_AXIS_INVALID) {
wlr_log(WLR_ERROR, "Invalid argument for action %s: '%s' (%s)", wlr_log(WLR_ERROR, "Invalid argument for action %s: '%s' (%s)",
action_names[action->type], argument, content); action_names[action->type], argument, content);
} else { } else {

View file

@ -119,33 +119,6 @@ parse_window_type(const char *type)
} }
} }
static void
parse_maximized_query(const char *content, struct view_query *query)
{
if (!query || !content) {
return;
}
query->maximized_full = LAB_STATE_UNSPECIFIED;
query->maximized_vertical = LAB_STATE_UNSPECIFIED;
query->maximized_horizontal = LAB_STATE_UNSPECIFIED;
if (!strcasecmp(content, "yes") || !strcasecmp(content, "full")) {
query->maximized_full = LAB_STATE_ENABLED;
} else if (!strcasecmp(content, "horizontal")) {
query->maximized_horizontal = LAB_STATE_ENABLED;
} else if (!strcasecmp(content, "vertical")) {
query->maximized_vertical = LAB_STATE_ENABLED;
} else if (!strcasecmp(content, "no") || !strcasecmp(content, "none")) {
query->maximized_full = LAB_STATE_DISABLED;
query->maximized_vertical = LAB_STATE_DISABLED;
query->maximized_horizontal = LAB_STATE_DISABLED;
} else {
wlr_log(WLR_ERROR,
"(%s) is not a valid maximized query state", content);
}
}
/* /*
* Openbox/labwc comparison * Openbox/labwc comparison
* *
@ -503,7 +476,7 @@ fill_action_query(char *nodename, char *content, struct action *action)
} else if (!strcasecmp(nodename, "shaded")) { } else if (!strcasecmp(nodename, "shaded")) {
current_view_query->shaded = parse_bool(content, -1); current_view_query->shaded = parse_bool(content, -1);
} else if (!strcasecmp(nodename, "maximized")) { } else if (!strcasecmp(nodename, "maximized")) {
parse_maximized_query(content, current_view_query); current_view_query->maximized = view_axis_parse(content);
} else if (!strcasecmp(nodename, "iconified")) { } else if (!strcasecmp(nodename, "iconified")) {
current_view_query->iconified = parse_bool(content, -1); current_view_query->iconified = parse_bool(content, -1);
} else if (!strcasecmp(nodename, "focused")) { } else if (!strcasecmp(nodename, "focused")) {

View file

@ -155,25 +155,11 @@ view_matches_query(struct view *view, struct view_query *query)
return false; return false;
} }
match = if (query->maximized != VIEW_AXIS_INVALID) {
match_tristate(query->maximized_full, match = bool_to_tristate(view->maximized == query->maximized);
(view->maximized == VIEW_AXIS_BOTH), match);
if (match == LAB_STATE_DISABLED) { if (match == LAB_STATE_DISABLED) {
return false; return false;
} }
match =
match_tristate(query->maximized_horizontal,
(view->maximized == VIEW_AXIS_HORIZONTAL), match);
if (match == LAB_STATE_DISABLED) {
return false;
}
match =
match_tristate(query->maximized_vertical,
(view->maximized == VIEW_AXIS_VERTICAL), match);
if (match == LAB_STATE_DISABLED) {
return false;
} }
match = match_tristate(query->iconified, view->minimized, match); match = match_tristate(query->iconified, view->minimized, match);
@ -2066,7 +2052,7 @@ enum view_axis
view_axis_parse(const char *direction) view_axis_parse(const char *direction)
{ {
if (!direction) { if (!direction) {
return VIEW_AXIS_NONE; return VIEW_AXIS_INVALID;
} }
if (!strcasecmp(direction, "horizontal")) { if (!strcasecmp(direction, "horizontal")) {
return VIEW_AXIS_HORIZONTAL; return VIEW_AXIS_HORIZONTAL;
@ -2074,8 +2060,10 @@ view_axis_parse(const char *direction)
return VIEW_AXIS_VERTICAL; return VIEW_AXIS_VERTICAL;
} else if (!strcasecmp(direction, "both")) { } else if (!strcasecmp(direction, "both")) {
return VIEW_AXIS_BOTH; return VIEW_AXIS_BOTH;
} else { } else if (!strcasecmp(direction, "none")) {
return VIEW_AXIS_NONE; return VIEW_AXIS_NONE;
} else {
return VIEW_AXIS_INVALID;
} }
} }