diff --git a/docs/labwc-actions.5.scd b/docs/labwc-actions.5.scd index c137bf62..9cb6ae53 100644 --- a/docs/labwc-actions.5.scd +++ b/docs/labwc-actions.5.scd @@ -391,25 +391,24 @@ Actions that execute other actions. Used in keyboard/mouse bindings. NET_WM_WINDOW_TYPE for XWayland clients. *shaded* [yes|no] - If the client is rolled down. + Whether or not the client is rolled up. - *maximized* [yes|no] - if the client is maximized on both axis. + *maximized* [yes|horizontal|vertical|no] + 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] - If the client is maximized on the horizontal axis. - - *maximizedvertical* [yes|no] - If the client is maximized on the vertical axis. + The keyword "full" may be used as a synonym for "yes", + while "none" may be used as a synonym for "no". *iconified* [yes|no] - If the client is iconified. + Whether or not the client is iconified. *focused* [yes|no] - If the client is focused. + Whether or not the client is focused. *omnipresent* [yes|no] - If the client is visible on all desktops. + Whether or not the client is visible on all desktops. *desktop* 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. *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* - If the client is tiled (snapped) in the specified + Whether the client is tiled (snapped) to the indicated region. This argument is optional. diff --git a/include/view.h b/include/view.h index ca1fa04a..0c2f621a 100644 --- a/include/view.h +++ b/include/view.h @@ -291,9 +291,9 @@ struct view_query { char *sandbox_engine; char *sandbox_app_id; enum three_state shaded; - enum three_state maximized; - enum three_state maximizedvertical; - enum three_state maximizedhorizontal; + enum three_state maximized_full; + enum three_state maximized_vertical; + enum three_state maximized_horizontal; enum three_state iconified; enum three_state focused; enum three_state omnipresent; diff --git a/src/config/rcxml.c b/src/config/rcxml.c index bfa9269d..7ab3aa1c 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -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 * @@ -476,11 +503,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")) { - current_view_query->maximized = parse_bool(content, -1); - } 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); + parse_maximized_query(content, current_view_query); } else if (!strcasecmp(nodename, "iconified")) { current_view_query->iconified = parse_bool(content, -1); } else if (!strcasecmp(nodename, "focused")) { diff --git a/src/view.c b/src/view.c index cad8ec59..11c5b5e6 100644 --- a/src/view.c +++ b/src/view.c @@ -70,9 +70,7 @@ struct view_query * view_query_create(void) { struct view_query *query = znew(*query); - *query = (struct view_query) { - .window_type = -1, - }; + query->window_type = -1; return query; } @@ -153,51 +151,48 @@ view_matches_query(struct view *view, struct view_query *query) } match = match_tristate(query->shaded, view->shaded, match); - wlr_log(WLR_DEBUG, "shaded: %d\n", match); if (match == LAB_STATE_DISABLED) { return false; } - match = match_tristate(query->maximized, (view->maximized == VIEW_AXIS_BOTH), match); - wlr_log(WLR_DEBUG, "maximized: %d\n", match); + match = + match_tristate(query->maximized_full, + (view->maximized == VIEW_AXIS_BOTH), match); if (match == LAB_STATE_DISABLED) { return false; } - match = match_tristate(query->maximizedhorizontal, - (view->maximized == VIEW_AXIS_HORIZONTAL), match); - wlr_log(WLR_DEBUG, "maximizedhorizontal: %d\n", match); + match = + match_tristate(query->maximized_horizontal, + (view->maximized == VIEW_AXIS_HORIZONTAL), match); if (match == LAB_STATE_DISABLED) { return false; } - match = match_tristate(query->maximizedvertical, - (view->maximized == VIEW_AXIS_VERTICAL), match); + 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); - wlr_log(WLR_DEBUG, "iconified: %d\n", match); if (match == LAB_STATE_DISABLED) { return false; } match = match_tristate(query->focused, view->server->active_view == view, match); - wlr_log(WLR_DEBUG, "focused: %d\n", match); if (match == LAB_STATE_DISABLED) { return false; } match = match_tristate(query->omnipresent, view->visible_on_all_workspaces, match); - wlr_log(WLR_DEBUG, "omnipresent: %d\n", match); if (match == LAB_STATE_DISABLED) { return false; } if (query->tiled != VIEW_EDGE_INVALID) { match = bool_to_tristate(query->tiled == view->tiled); - wlr_log(WLR_DEBUG, "tiled: %d\n", match); if (match == LAB_STATE_DISABLED) { return false; } @@ -206,7 +201,6 @@ view_matches_query(struct view *view, struct view_query *query) if (query->tiled_region) { 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; }