parser: add CfgApplyEffects struct, extend CfgRule and parse_rules()
This commit is contained in:
+35
-3
@@ -296,9 +296,41 @@ parse_rules(lua_State *L, Config *cfg)
|
||||
memset(r, 0, sizeof(*r));
|
||||
lua_get_string(L, "app_id", r->app_id, sizeof(r->app_id));
|
||||
lua_get_string(L, "title", r->title, sizeof(r->title));
|
||||
r->tags = (uint32_t)lua_get_int(L, "tags", 0);
|
||||
r->floating = lua_get_bool(L, "floating", false);
|
||||
r->monitor = lua_get_int(L, "monitor", -1);
|
||||
r->floating = lua_get_bool(L, "floating", false);
|
||||
r->fullscreen = lua_get_bool(L, "fullscreen", false);
|
||||
r->can_float = lua_get_bool(L, "can_float", true);
|
||||
r->can_fullscreen = lua_get_bool(L, "can_fullscreen", true);
|
||||
|
||||
/* tags string coercion: "any" → 0 */
|
||||
lua_getfield(L, -1, "tags");
|
||||
if (lua_isstring(L, -1) && !strcmp(lua_tostring(L, -1), "any"))
|
||||
r->tags = 0;
|
||||
else
|
||||
r->tags = (uint32_t)(lua_isnumber(L, -1) ? (int)lua_tointeger(L, -1) : 0);
|
||||
lua_pop(L, 1);
|
||||
|
||||
/* monitor string coercion: "default" → -1 */
|
||||
lua_getfield(L, -1, "monitor");
|
||||
if (lua_isstring(L, -1) && !strcmp(lua_tostring(L, -1), "default"))
|
||||
r->monitor = -1;
|
||||
else
|
||||
r->monitor = lua_isnumber(L, -1) ? (int)lua_tointeger(L, -1) : -1;
|
||||
lua_pop(L, 1);
|
||||
|
||||
/* apply_effects sub-table — all default true */
|
||||
memset(&r->apply_effects, 1, sizeof(r->apply_effects));
|
||||
lua_getfield(L, -1, "apply_effects");
|
||||
if (lua_istable(L, -1)) {
|
||||
r->apply_effects.rounding = lua_get_bool(L, "rounding", true);
|
||||
r->apply_effects.shadows = lua_get_bool(L, "shadows", true);
|
||||
r->apply_effects.transparency = lua_get_bool(L, "transparency", true);
|
||||
r->apply_effects.blur = lua_get_bool(L, "blur", true);
|
||||
r->apply_effects.gaps = lua_get_bool(L, "gaps", true);
|
||||
r->apply_effects.smartgaps = lua_get_bool(L, "smartgaps", true);
|
||||
r->apply_effects.border = lua_get_bool(L, "border", true);
|
||||
r->apply_effects.sloppy_focus = lua_get_bool(L, "sloppy_focus", true);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user