mirror of
https://github.com/labwc/labwc.git
synced 2026-04-11 08:21:13 -04:00
query: eliminate query.maximized tristates
This commit is contained in:
parent
9247236938
commit
ac2d1b4177
4 changed files with 13 additions and 53 deletions
|
|
@ -53,6 +53,7 @@ enum three_state {
|
|||
* Therefore when parsing rc.xml, "None" means "Invalid".
|
||||
*/
|
||||
enum view_axis {
|
||||
VIEW_AXIS_INVALID = -1,
|
||||
VIEW_AXIS_NONE = 0,
|
||||
VIEW_AXIS_HORIZONTAL = (1 << 0),
|
||||
VIEW_AXIS_VERTICAL = (1 << 1),
|
||||
|
|
@ -291,9 +292,7 @@ struct view_query {
|
|||
char *sandbox_engine;
|
||||
char *sandbox_app_id;
|
||||
enum three_state shaded;
|
||||
enum three_state maximized_full;
|
||||
enum three_state maximized_vertical;
|
||||
enum three_state maximized_horizontal;
|
||||
enum view_axis maximized;
|
||||
enum three_state iconified;
|
||||
enum three_state focused;
|
||||
enum three_state omnipresent;
|
||||
|
|
|
|||
|
|
@ -366,7 +366,7 @@ action_arg_from_xml_node(struct action *action, const char *nodename, const char
|
|||
case ACTION_TYPE_UNMAXIMIZE:
|
||||
if (!strcmp(argument, "direction")) {
|
||||
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)",
|
||||
action_names[action->type], argument, content);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*
|
||||
|
|
@ -503,7 +476,7 @@ fill_action_query(char *nodename, char *content, struct action *action)
|
|||
} else if (!strcasecmp(nodename, "shaded")) {
|
||||
current_view_query->shaded = parse_bool(content, -1);
|
||||
} 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")) {
|
||||
current_view_query->iconified = parse_bool(content, -1);
|
||||
} else if (!strcasecmp(nodename, "focused")) {
|
||||
|
|
|
|||
30
src/view.c
30
src/view.c
|
|
@ -155,25 +155,11 @@ view_matches_query(struct view *view, struct view_query *query)
|
|||
return false;
|
||||
}
|
||||
|
||||
match =
|
||||
match_tristate(query->maximized_full,
|
||||
(view->maximized == VIEW_AXIS_BOTH), match);
|
||||
if (match == LAB_STATE_DISABLED) {
|
||||
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;
|
||||
if (query->maximized != VIEW_AXIS_INVALID) {
|
||||
match = bool_to_tristate(view->maximized == query->maximized);
|
||||
if (match == LAB_STATE_DISABLED) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
match = match_tristate(query->iconified, view->minimized, match);
|
||||
|
|
@ -2066,7 +2052,7 @@ enum view_axis
|
|||
view_axis_parse(const char *direction)
|
||||
{
|
||||
if (!direction) {
|
||||
return VIEW_AXIS_NONE;
|
||||
return VIEW_AXIS_INVALID;
|
||||
}
|
||||
if (!strcasecmp(direction, "horizontal")) {
|
||||
return VIEW_AXIS_HORIZONTAL;
|
||||
|
|
@ -2074,8 +2060,10 @@ view_axis_parse(const char *direction)
|
|||
return VIEW_AXIS_VERTICAL;
|
||||
} else if (!strcasecmp(direction, "both")) {
|
||||
return VIEW_AXIS_BOTH;
|
||||
} else {
|
||||
} else if (!strcasecmp(direction, "none")) {
|
||||
return VIEW_AXIS_NONE;
|
||||
} else {
|
||||
return VIEW_AXIS_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue