parser: add CfgApplyEffects struct, extend CfgRule and parse_rules()

This commit is contained in:
2026-07-03 04:17:40 -04:00
parent 6f8f2bbf94
commit 310be15cf3
2 changed files with 52 additions and 3 deletions
+35 -3
View File
@@ -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);
}
+17
View File
@@ -45,6 +45,19 @@ typedef struct {
int tap_button_map; /* libinput enum value */
} CfgInput;
/* Per-window apply-effects mask */
typedef struct {
bool rounding;
bool shadows;
bool transparency;
bool blur;
bool gaps;
bool smartgaps;
bool border;
bool sloppy_focus;
} CfgApplyEffects;
/* Window Rules */
typedef struct {
@@ -52,6 +65,10 @@ typedef struct {
char title[CFG_MAX_STRLEN]; /* empty string = wildcard */
uint32_t tags;
bool floating;
bool fullscreen;
bool can_float;
bool can_fullscreen;
CfgApplyEffects apply_effects;
int monitor; /* -1 = current */
} CfgRule;