From 13ff64f6e4e90916579521eb227ea72ab7a99353 Mon Sep 17 00:00:00 2001 From: lynxy Date: Thu, 3 Jul 2025 00:04:27 +0200 Subject: [PATCH] actions: added query tiled=any comparison for rc.xml simplification --- docs/labwc-actions.5.scd | 2 +- include/view.h | 13 ++++++++----- src/view.c | 4 +++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/docs/labwc-actions.5.scd b/docs/labwc-actions.5.scd index bf760fdb..52a3d2fb 100644 --- a/docs/labwc-actions.5.scd +++ b/docs/labwc-actions.5.scd @@ -474,7 +474,7 @@ Actions that execute other actions. Used in keyboard/mouse bindings. The "left" , "right", "left-occupied" and "right-occupied" directions will not wrap. - *tiled* [up|right|down|left|center] + *tiled* [up|right|down|left|center|any] Whether the client is tiled (snapped) along the the indicated screen edge. diff --git a/include/view.h b/include/view.h index 2ea83cd7..c4824803 100644 --- a/include/view.h +++ b/include/view.h @@ -62,11 +62,14 @@ enum view_axis { enum view_edge { VIEW_EDGE_INVALID = 0, - VIEW_EDGE_LEFT, - VIEW_EDGE_RIGHT, - VIEW_EDGE_UP, - VIEW_EDGE_DOWN, - VIEW_EDGE_CENTER, + VIEW_EDGE_LEFT = (1 << 0), + VIEW_EDGE_RIGHT = (1 << 1), + VIEW_EDGE_UP = (1 << 2), + VIEW_EDGE_DOWN = (1 << 3), + VIEW_EDGE_CENTER = (1 << 4), + + VIEW_EDGE_ALL = (VIEW_EDGE_LEFT | VIEW_EDGE_RIGHT | + VIEW_EDGE_UP | VIEW_EDGE_DOWN | VIEW_EDGE_CENTER), }; enum view_wants_focus { diff --git a/src/view.c b/src/view.c index 59c32e27..1a9d92cc 100644 --- a/src/view.c +++ b/src/view.c @@ -166,7 +166,7 @@ view_matches_query(struct view *view, struct view_query *query) return false; } - if (query->tiled != VIEW_EDGE_INVALID && query->tiled != view->tiled) { + if (query->tiled != VIEW_EDGE_INVALID && !(query->tiled & view->tiled)) { return false; } @@ -2116,6 +2116,8 @@ view_edge_parse(const char *direction) return VIEW_EDGE_DOWN; } else if (!strcasecmp(direction, "center")) { return VIEW_EDGE_CENTER; + } else if (!strcasecmp(direction, "any")) { + return VIEW_EDGE_ALL; } else { return VIEW_EDGE_INVALID; } -- 2.52.0