From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Mon, 27 May 2024 17:55:16 +0000 (+0200) Subject: ForEach: initialize view query window_type correctly X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=6f3f2aae27a6b8b2409055cafe48eb2f82c22263;p=proto%2Flabwc.git ForEach: initialize view query window_type correctly Before this patch, the window type would be checked even if not actually requested to do so. Fixes: #1852 --- diff --git a/include/view.h b/include/view.h index e9419158..c2366278 100644 --- a/include/view.h +++ b/include/view.h @@ -305,6 +305,13 @@ enum lab_view_criteria { */ struct view *view_from_wlr_surface(struct wlr_surface *surface); +/** + * view_query_create() - Create a new heap allocated view query with + * all members initialized to their default values (window_type = -1, + * NULL for strings) + */ +struct view_query *view_query_create(void); + /** * view_query_free() - Free a given view query * @query: Query to be freed. diff --git a/src/config/rcxml.c b/src/config/rcxml.c index 4af7ed46..67cbd421 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -313,7 +313,7 @@ fill_action_query(char *nodename, char *content, struct action *action) action_arg_add_querylist(action, "query"); queries = action_get_querylist(action, "query"); } - current_view_query = znew(*current_view_query); + current_view_query = view_query_create(); wl_list_append(queries, ¤t_view_query->link); } diff --git a/src/view.c b/src/view.c index f79f3e3c..d4bb1f0f 100644 --- a/src/view.c +++ b/src/view.c @@ -53,6 +53,14 @@ view_from_wlr_surface(struct wlr_surface *surface) return NULL; } +struct view_query * +view_query_create(void) +{ + struct view_query *query = znew(*query); + query->window_type = -1; + return query; +} + void view_query_free(struct view_query *query) {