build: add -ldl linker flag, recursive source discovery, and API test targets to Makefile

This commit is contained in:
2026-02-07 12:04:52 +00:00
parent 8e86b2d106
commit cd9e55dc64
181 changed files with 20646 additions and 7198 deletions
+89
View File
@@ -97,6 +97,9 @@ void config_set_defaults(Config *cfg)
cfg->demo_ai_timeout_ms = 15000;
cfg->demo_window_timeout_ms = 5000;
cfg->fade_speed = 0.5f; /* Default moderate speed */
cfg->fade_intensity = 1.0f; /* Default full intensity */
strncpy(cfg->color_panel_bg, DEFAULT_PANEL_BG, sizeof(cfg->color_panel_bg) - 1);
strncpy(cfg->color_panel_fg, DEFAULT_PANEL_FG, sizeof(cfg->color_panel_fg) - 1);
strncpy(cfg->color_workspace_active, DEFAULT_WS_ACTIVE, sizeof(cfg->color_workspace_active) - 1);
@@ -227,6 +230,14 @@ static void handle_config_entry(const char *section, const char *key,
int val = atoi(value);
cfg->demo_window_timeout_ms = (val >= 1000 && val <= 30000) ? val : 5000;
}
} else if (strcmp(section, "effects") == 0) {
if (strcmp(key, "fade_speed") == 0) {
float val = atof(value);
cfg->fade_speed = (val >= 0.1f && val <= 3.0f) ? val : 0.5f;
} else if (strcmp(key, "fade_intensity") == 0) {
float val = atof(value);
cfg->fade_intensity = (val >= 0.0f && val <= 1.0f) ? val : 1.0f;
}
} else if (strcmp(section, "colors") == 0) {
if (strcmp(key, "panel_bg") == 0) {
strncpy(cfg->color_panel_bg, value, sizeof(cfg->color_panel_bg) - 1);
@@ -350,9 +361,53 @@ bool config_load(Config *cfg, const char *path)
LOG_INFO("AI features enabled");
}
/* Validate and clamp all config values to safe ranges */
config_validate(cfg);
return true;
}
void config_validate(Config *cfg)
{
if (cfg == NULL) return;
/* Panel height: 10-100 pixels */
if (cfg->panel_height < 10) cfg->panel_height = 10;
if (cfg->panel_height > 100) cfg->panel_height = 100;
/* Border width: 0-20 pixels */
if (cfg->border_width < 0) cfg->border_width = 0;
if (cfg->border_width > 20) cfg->border_width = 20;
/* Title height: 0-50 pixels */
if (cfg->title_height < 0) cfg->title_height = 0;
if (cfg->title_height > 50) cfg->title_height = 50;
/* Default master ratio: 0.1-0.9 */
if (cfg->default_master_ratio < 0.1f) cfg->default_master_ratio = 0.1f;
if (cfg->default_master_ratio > 0.9f) cfg->default_master_ratio = 0.9f;
/* Default master count: 1-8 */
if (cfg->default_master_count < 1) cfg->default_master_count = 1;
if (cfg->default_master_count > 8) cfg->default_master_count = 8;
/* Gap: 0-50 pixels */
if (cfg->gap < 0) cfg->gap = 0;
if (cfg->gap > 50) cfg->gap = 50;
/* Fade speed: 0.1-3.0 */
if (cfg->fade_speed < 0.1f) cfg->fade_speed = 0.1f;
if (cfg->fade_speed > 3.0f) cfg->fade_speed = 3.0f;
/* Fade intensity: 0.0-1.0 */
if (cfg->fade_intensity < 0.0f) cfg->fade_intensity = 0.0f;
if (cfg->fade_intensity > 1.0f) cfg->fade_intensity = 1.0f;
/* API port: 1024-65535 (avoid well-known ports) */
if (cfg->api_port < 1024) cfg->api_port = 8777;
if (cfg->api_port > 65535) cfg->api_port = 8777;
}
bool config_reload(Config *cfg)
{
if (cfg == NULL) {
@@ -440,3 +495,37 @@ void config_init_colors(Config *cfg)
cfg->colors.notification_bg = parse_color(cfg->color_notification_bg);
cfg->colors.notification_fg = parse_color(cfg->color_notification_fg);
}
float config_get_fade_speed(void)
{
if (dwn != NULL && dwn->config != NULL) {
return dwn->config->fade_speed;
}
return 0.5f;
}
float config_get_fade_intensity(void)
{
if (dwn != NULL && dwn->config != NULL) {
return dwn->config->fade_intensity;
}
return 1.0f;
}
void config_set_fade_speed(float speed)
{
if (dwn != NULL && dwn->config != NULL) {
if (speed < 0.1f) speed = 0.1f;
if (speed > 3.0f) speed = 3.0f;
dwn->config->fade_speed = speed;
}
}
void config_set_fade_intensity(float intensity)
{
if (dwn != NULL && dwn->config != NULL) {
if (intensity < 0.0f) intensity = 0.0f;
if (intensity > 1.0f) intensity = 1.0f;
dwn->config->fade_intensity = intensity;
}
}