From e6613f766dc49ccd7ff8121faffccdc61bd20e1d Mon Sep 17 00:00:00 2001 From: HuntedByTheIRS Date: Thu, 2 Jul 2026 19:44:06 -0400 Subject: [PATCH] refactor(parser): export parse_color_hex for compositor use Remove 'static' from parse_color_hex() in parser.c and add a public declaration to parser.h so src/peachwm.c can call it for shadow color conversion. No changes to function body. --- parser/parser.c | 37 ++++++++++++++++++++++++++++++++++++- parser/parser.h | 22 ++++++++++++++++++++-- 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/parser/parser.c b/parser/parser.c index bb49f25..431fec9 100644 --- a/parser/parser.c +++ b/parser/parser.c @@ -97,7 +97,7 @@ lua_get_bool(lua_State *L, const char *key, bool def) return val; } -static void +void parse_color_hex(uint32_t hex, float out[4]) { out[0] = ((hex >> 24) & 0xFF) / 255.0f; @@ -618,6 +618,39 @@ parse_autostart(lua_State *L, Config *cfg) lua_pop(L, 1); } +static void +parse_shadows(lua_State *L, CfgEffectsWindowShadows *s) +{ + /* Sub-table defaults are zero-initialized by memset in config_load */ + lua_getfield(L, -1, "shadows"); + if (!lua_istable(L, -1)) { + lua_pop(L, 1); + return; + } + + s->shadows = lua_get_bool(L, "shadows", false); + s->shadow_radius = lua_get_int(L, "shadow_radius", 0); + if (s->shadow_radius < 0) s->shadow_radius = 0; + s->shadow_offset_x = lua_get_int(L, "shadow_offset_x", 0); + s->shadow_offset_y = lua_get_int(L, "shadow_offset_y", 0); + s->shadow_expand = lua_get_int(L, "shadow_expand", 0); + if (s->shadow_expand < 0) s->shadow_expand = 0; + s->shadow_color = (uint32_t)lua_get_int(L, "shadow_color", 0); + + double op = lua_get_double(L, "shadow_opacity", 0.0); + if (op < 0.0) op = 0.0; + if (op > 1.0) op = 1.0; + s->shadow_opacity = (float)op; + + s->fullscreen_shadows = lua_get_bool(L, "fullscreen_shadows", false); + s->nogaps_shadows = lua_get_bool(L, "nogaps_shadows", false); + s->maximized_shadows = lua_get_bool(L, "maximized_shadows", false); + s->only_floating = lua_get_bool(L, "only_floating", false); + s->shadow_clip = lua_get_bool(L, "shadow_clip", false); + + lua_pop(L, 1); /* pop shadows table */ +} + static void parse_effects(lua_State *L, CfgEffects *e) { @@ -646,6 +679,8 @@ parse_effects(lua_State *L, CfgEffects *e) else strcpy(e->windows.rounding, "off"); + parse_shadows(L, &e->windows.shadows); + lua_pop(L, 2); /* pop windows + effects */ } diff --git a/parser/parser.h b/parser/parser.h index c272e71..40b3464 100644 --- a/parser/parser.h +++ b/parser/parser.h @@ -107,8 +107,24 @@ typedef struct { /* Effects */ typedef struct { - bool rounded; - char rounding[CFG_MAX_STRLEN]; + bool shadows; + int shadow_radius; + int shadow_offset_x; + int shadow_offset_y; + uint32_t shadow_color; + float shadow_opacity; + int shadow_expand; + bool fullscreen_shadows; + bool nogaps_shadows; + bool maximized_shadows; + bool only_floating; + bool shadow_clip; +} CfgEffectsWindowShadows; + +typedef struct { + bool rounded; + char rounding[CFG_MAX_STRLEN]; + CfgEffectsWindowShadows shadows; } CfgEffectsWindows; typedef struct { @@ -158,6 +174,8 @@ char *config_get_path(char *buf, size_t bufsz); void config_autostart_run(const Config *cfg); +void parse_color_hex(uint32_t hex, float out[4]); + typedef void (*config_reload_cb)(const Config *cfg, void *userdata); typedef struct WatchState WatchState;