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.
This commit is contained in:
2026-07-02 19:44:06 -04:00
parent 2b603a8c87
commit e6613f766d
2 changed files with 56 additions and 3 deletions
+36 -1
View File
@@ -97,7 +97,7 @@ lua_get_bool(lua_State *L, const char *key, bool def)
return val; return val;
} }
static void void
parse_color_hex(uint32_t hex, float out[4]) parse_color_hex(uint32_t hex, float out[4])
{ {
out[0] = ((hex >> 24) & 0xFF) / 255.0f; out[0] = ((hex >> 24) & 0xFF) / 255.0f;
@@ -618,6 +618,39 @@ parse_autostart(lua_State *L, Config *cfg)
lua_pop(L, 1); 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 static void
parse_effects(lua_State *L, CfgEffects *e) parse_effects(lua_State *L, CfgEffects *e)
{ {
@@ -646,6 +679,8 @@ parse_effects(lua_State *L, CfgEffects *e)
else else
strcpy(e->windows.rounding, "off"); strcpy(e->windows.rounding, "off");
parse_shadows(L, &e->windows.shadows);
lua_pop(L, 2); /* pop windows + effects */ lua_pop(L, 2); /* pop windows + effects */
} }
+20 -2
View File
@@ -107,8 +107,24 @@ typedef struct {
/* Effects */ /* Effects */
typedef struct { typedef struct {
bool rounded; bool shadows;
char rounding[CFG_MAX_STRLEN]; 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; } CfgEffectsWindows;
typedef struct { typedef struct {
@@ -158,6 +174,8 @@ char *config_get_path(char *buf, size_t bufsz);
void config_autostart_run(const Config *cfg); 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 void (*config_reload_cb)(const Config *cfg, void *userdata);
typedef struct WatchState WatchState; typedef struct WatchState WatchState;