]> git.mdlowis.com Git - proto/labwc.git/commitdiff
src/config/rcxml.c: move region validation into the validate() hook
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Fri, 12 May 2023 11:53:50 +0000 (13:53 +0200)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Fri, 12 May 2023 17:30:59 +0000 (19:30 +0200)
src/config/rcxml.c

index f52f980f83043c04a6aed4dc8733808feb39e5f1..03e1594040ff0d3bd9aa074f5010d3989f1b83f9 100644 (file)
@@ -1014,24 +1014,6 @@ post_processing(void)
        if (rc.workspace_config.popuptime == INT_MIN) {
                rc.workspace_config.popuptime = 1000;
        }
-       struct region *region, *region_tmp;
-       wl_list_for_each_safe(region, region_tmp, &rc.regions, link) {
-               struct wlr_box box = region->percentage;
-               bool invalid = !region->name
-                       || box.x < 0 || box.x > 100
-                       || box.y < 0 || box.y > 100
-                       || box.width <= 0 || box.width > 100
-                       || box.height <= 0 || box.height > 100;
-               if (invalid) {
-                       wlr_log(WLR_ERROR,
-                               "Removing invalid region '%s': %d%% x %d%% @ %d%%,%d%%",
-                               region->name, box.width, box.height, box.x, box.y);
-                       wl_list_remove(&region->link);
-                       zfree(region->name);
-                       free(region);
-               }
-       }
-
        if (!wl_list_length(&rc.window_switcher.fields)) {
                wlr_log(WLR_INFO, "load default window switcher fields");
                load_default_window_switcher_fields();
@@ -1051,11 +1033,30 @@ rule_destroy(struct window_rule *rule)
 static void
 validate(void)
 {
+       /* Regions */
+       struct region *region, *region_tmp;
+       wl_list_for_each_safe(region, region_tmp, &rc.regions, link) {
+               struct wlr_box box = region->percentage;
+               bool invalid = !region->name
+                       || box.x < 0 || box.x > 100
+                       || box.y < 0 || box.y > 100
+                       || box.width <= 0 || box.width > 100
+                       || box.height <= 0 || box.height > 100;
+               if (invalid) {
+                       wlr_log(WLR_ERROR,
+                               "Removing invalid region '%s': %d%% x %d%% @ %d%%,%d%%",
+                               region->name, box.width, box.height, box.x, box.y);
+                       wl_list_remove(&region->link);
+                       zfree(region->name);
+                       free(region);
+               }
+       }
+
        /* Window-rule criteria */
        struct window_rule *rule, *next;
        wl_list_for_each_safe(rule, next, &rc.window_rules, link) {
                if (!rule->identifier && !rule->title) {
-                       wlr_log(WLR_ERROR, "deleting rule %p as no criteria", rule);
+                       wlr_log(WLR_ERROR, "Deleting rule %p as it has no criteria", rule);
                        rule_destroy(rule);
                }
        }