]> git.mdlowis.com Git - proto/labwc.git/commitdiff
ForEach: initialize view query window_type correctly
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Mon, 27 May 2024 17:55:16 +0000 (19:55 +0200)
committerJohan Malm <johanmalm@users.noreply.github.com>
Mon, 27 May 2024 18:59:06 +0000 (19:59 +0100)
Before this patch, the window type would be checked even if
not actually requested to do so.

Fixes: #1852
include/view.h
src/config/rcxml.c
src/view.c

index e941915899f402fe6bc4e9c4644df52d126daac5..c236627814b57975f91d586a329ff7f16b87aff3 100644 (file)
@@ -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.
index 4af7ed464c44bbe7e694bfc6bc5aacc9ca2b86c0..67cbd421ed7792fb473d04b71b61fb45f83f311f 100644 (file)
@@ -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, &current_view_query->link);
        }
 
index f79f3e3c7b20a13bf862618b941435e6fd1eb212..d4bb1f0f93ba30ee3e8dcfa8d9116f1b146671b8 100644 (file)
@@ -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)
 {