From 7347f7f05fcd343443d7718fad58e3c392893b2f Mon Sep 17 00:00:00 2001 From: Tobias Bengfort Date: Sat, 20 Apr 2024 07:57:35 +0200 Subject: [PATCH] query: add window type filter for if-actions --- docs/labwc-actions.5.scd | 4 ++++ include/view.h | 1 + src/config/rcxml.c | 2 ++ src/view.c | 5 +++++ 4 files changed, 12 insertions(+) diff --git a/docs/labwc-actions.5.scd b/docs/labwc-actions.5.scd index 3353fcfa..313f98f1 100644 --- a/docs/labwc-actions.5.scd +++ b/docs/labwc-actions.5.scd @@ -304,6 +304,10 @@ Actions that execute other actions. Used in keyboard/mouse bindings. XDG shell title for Wayland clients, WM_NAME for XWayland clients. + *type* + Internal heuristics for Wayland clients, + NET_WM_WINDOW_TYPE for XWayland clients. + This argument is optional. *then* diff --git a/include/view.h b/include/view.h index 0cc3cfbd..cbaebcc9 100644 --- a/include/view.h +++ b/include/view.h @@ -262,6 +262,7 @@ struct view_query { struct wl_list link; char *identifier; char *title; + int window_type; }; struct xdg_toplevel_view { diff --git a/src/config/rcxml.c b/src/config/rcxml.c index 1262f035..77c5393a 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -314,6 +314,8 @@ fill_action_query(char *nodename, char *content, struct action *action) current_view_query->identifier = xstrdup(content); } else if (!strcasecmp(nodename, "title")) { current_view_query->title = xstrdup(content); + } else if (!strcmp(nodename, "type")) { + current_view_query->window_type = parse_window_type(content); } } diff --git a/src/view.c b/src/view.c index 19b5a33a..e7169540 100644 --- a/src/view.c +++ b/src/view.c @@ -80,6 +80,11 @@ view_matches_query(struct view *view, struct view_query *query) match &= match_glob(query->title, title); } + if (match && query->window_type >= 0) { + empty = false; + match &= view_contains_window_type(view, query->window_type); + } + return !empty && match; }