mirror of
https://github.com/labwc/labwc.git
synced 2026-04-11 08:21:13 -04:00
query: simplify maximized query syntax
This commit is contained in:
parent
66373a5fdd
commit
9247236938
4 changed files with 54 additions and 37 deletions
|
|
@ -391,25 +391,24 @@ Actions that execute other actions. Used in keyboard/mouse bindings.
|
||||||
NET_WM_WINDOW_TYPE for XWayland clients.
|
NET_WM_WINDOW_TYPE for XWayland clients.
|
||||||
|
|
||||||
*shaded* [yes|no]
|
*shaded* [yes|no]
|
||||||
If the client is rolled down.
|
Whether or not the client is rolled up.
|
||||||
|
|
||||||
*maximized* [yes|no]
|
*maximized* [yes|horizontal|vertical|no]
|
||||||
if the client is maximized on both axis.
|
Whether the client is maximized along both axes (yes),
|
||||||
|
the horizontal axis only (horizontal), the vertical
|
||||||
|
axis only (vertical) or neither axis (no).
|
||||||
|
|
||||||
*maximizedhorizontal* [yes|no]
|
The keyword "full" may be used as a synonym for "yes",
|
||||||
If the client is maximized on the horizontal axis.
|
while "none" may be used as a synonym for "no".
|
||||||
|
|
||||||
*maximizedvertical* [yes|no]
|
|
||||||
If the client is maximized on the vertical axis.
|
|
||||||
|
|
||||||
*iconified* [yes|no]
|
*iconified* [yes|no]
|
||||||
If the client is iconified.
|
Whether or not the client is iconified.
|
||||||
|
|
||||||
*focused* [yes|no]
|
*focused* [yes|no]
|
||||||
If the client is focused.
|
Whether or not the client is focused.
|
||||||
|
|
||||||
*omnipresent* [yes|no]
|
*omnipresent* [yes|no]
|
||||||
If the client is visible on all desktops.
|
Whether or not the client is visible on all desktops.
|
||||||
|
|
||||||
*desktop*
|
*desktop*
|
||||||
The desktop the client is currently on. This can be the
|
The desktop the client is currently on. This can be the
|
||||||
|
|
@ -418,10 +417,11 @@ Actions that execute other actions. Used in keyboard/mouse bindings.
|
||||||
"left" and "right" are hardcoded to not wrap.
|
"left" and "right" are hardcoded to not wrap.
|
||||||
|
|
||||||
*tiled* [up|right|down|left|center]
|
*tiled* [up|right|down|left|center]
|
||||||
If the client is tiled (snapped) in the specified edge.
|
Whether the client is tiled (snapped) along the the
|
||||||
|
indicated screen edge.
|
||||||
|
|
||||||
*tiled_region*
|
*tiled_region*
|
||||||
If the client is tiled (snapped) in the specified
|
Whether the client is tiled (snapped) to the indicated
|
||||||
region.
|
region.
|
||||||
|
|
||||||
This argument is optional.
|
This argument is optional.
|
||||||
|
|
|
||||||
|
|
@ -291,9 +291,9 @@ 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;
|
enum three_state maximized_full;
|
||||||
enum three_state maximizedvertical;
|
enum three_state maximized_vertical;
|
||||||
enum three_state maximizedhorizontal;
|
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;
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,33 @@ 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
|
||||||
*
|
*
|
||||||
|
|
@ -476,11 +503,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")) {
|
||||||
current_view_query->maximized = parse_bool(content, -1);
|
parse_maximized_query(content, current_view_query);
|
||||||
} else if (!strcasecmp(nodename, "maximizedhorizontal")) {
|
|
||||||
current_view_query->maximizedhorizontal = parse_bool(content, -1);
|
|
||||||
} else if (!strcasecmp(nodename, "maximizedvertical")) {
|
|
||||||
current_view_query->maximizedvertical = parse_bool(content, -1);
|
|
||||||
} 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")) {
|
||||||
|
|
|
||||||
26
src/view.c
26
src/view.c
|
|
@ -70,9 +70,7 @@ struct view_query *
|
||||||
view_query_create(void)
|
view_query_create(void)
|
||||||
{
|
{
|
||||||
struct view_query *query = znew(*query);
|
struct view_query *query = znew(*query);
|
||||||
*query = (struct view_query) {
|
query->window_type = -1;
|
||||||
.window_type = -1,
|
|
||||||
};
|
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -153,51 +151,48 @@ view_matches_query(struct view *view, struct view_query *query)
|
||||||
}
|
}
|
||||||
|
|
||||||
match = match_tristate(query->shaded, view->shaded, match);
|
match = match_tristate(query->shaded, view->shaded, match);
|
||||||
wlr_log(WLR_DEBUG, "shaded: %d\n", match);
|
|
||||||
if (match == LAB_STATE_DISABLED) {
|
if (match == LAB_STATE_DISABLED) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
match = match_tristate(query->maximized, (view->maximized == VIEW_AXIS_BOTH), match);
|
match =
|
||||||
wlr_log(WLR_DEBUG, "maximized: %d\n", match);
|
match_tristate(query->maximized_full,
|
||||||
|
(view->maximized == VIEW_AXIS_BOTH), match);
|
||||||
if (match == LAB_STATE_DISABLED) {
|
if (match == LAB_STATE_DISABLED) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
match = match_tristate(query->maximizedhorizontal,
|
match =
|
||||||
(view->maximized == VIEW_AXIS_HORIZONTAL), match);
|
match_tristate(query->maximized_horizontal,
|
||||||
wlr_log(WLR_DEBUG, "maximizedhorizontal: %d\n", match);
|
(view->maximized == VIEW_AXIS_HORIZONTAL), match);
|
||||||
if (match == LAB_STATE_DISABLED) {
|
if (match == LAB_STATE_DISABLED) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
match = match_tristate(query->maximizedvertical,
|
match =
|
||||||
(view->maximized == VIEW_AXIS_VERTICAL), match);
|
match_tristate(query->maximized_vertical,
|
||||||
|
(view->maximized == VIEW_AXIS_VERTICAL), match);
|
||||||
if (match == LAB_STATE_DISABLED) {
|
if (match == LAB_STATE_DISABLED) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
match = match_tristate(query->iconified, view->minimized, match);
|
match = match_tristate(query->iconified, view->minimized, match);
|
||||||
wlr_log(WLR_DEBUG, "iconified: %d\n", match);
|
|
||||||
if (match == LAB_STATE_DISABLED) {
|
if (match == LAB_STATE_DISABLED) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
match = match_tristate(query->focused, view->server->active_view == view, match);
|
match = match_tristate(query->focused, view->server->active_view == view, match);
|
||||||
wlr_log(WLR_DEBUG, "focused: %d\n", match);
|
|
||||||
if (match == LAB_STATE_DISABLED) {
|
if (match == LAB_STATE_DISABLED) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
match = match_tristate(query->omnipresent, view->visible_on_all_workspaces, match);
|
match = match_tristate(query->omnipresent, view->visible_on_all_workspaces, match);
|
||||||
wlr_log(WLR_DEBUG, "omnipresent: %d\n", match);
|
|
||||||
if (match == LAB_STATE_DISABLED) {
|
if (match == LAB_STATE_DISABLED) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query->tiled != VIEW_EDGE_INVALID) {
|
if (query->tiled != VIEW_EDGE_INVALID) {
|
||||||
match = bool_to_tristate(query->tiled == view->tiled);
|
match = bool_to_tristate(query->tiled == view->tiled);
|
||||||
wlr_log(WLR_DEBUG, "tiled: %d\n", match);
|
|
||||||
if (match == LAB_STATE_DISABLED) {
|
if (match == LAB_STATE_DISABLED) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -206,7 +201,6 @@ view_matches_query(struct view *view, struct view_query *query)
|
||||||
if (query->tiled_region) {
|
if (query->tiled_region) {
|
||||||
match = bool_to_tristate(view->tiled_region &&
|
match = bool_to_tristate(view->tiled_region &&
|
||||||
!strcasecmp(query->tiled_region, view->tiled_region->name));
|
!strcasecmp(query->tiled_region, view->tiled_region->name));
|
||||||
wlr_log(WLR_DEBUG, "tiled_region: %d\n", match);
|
|
||||||
if (match == LAB_STATE_DISABLED) {
|
if (match == LAB_STATE_DISABLED) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue