feat: add dpi detection and configuration for mouse distance

Implement automatic DPI detection from EDID display data and a manual `mouse_distance_dpi` config option to convert mouse movement pixels into real-world centimeters. The new `calculate_pixels_per_cm()` function in main.c falls back to manual DPI override, then EDID-based auto-detection with sanity checks, and finally a default 96 DPI (37.8 px/cm). The `Config` struct gains a `mouse_distance_dpi` field parsed from config files, and `DWNState` stores the computed `pixels_per_cm` and a `dpi_auto_detected` flag. The panel renderer now uses `dwn->pixels_per_cm` instead of the hardcoded 37.8 constant for mouse distance display.
This commit is contained in:
2026-01-28 15:55:00 +00:00
parent 2303b53c70
commit 5404adfcd5
17 changed files with 47 additions and 1 deletions
+4
View File
@@ -61,6 +61,7 @@ void config_set_defaults(Config *cfg)
cfg->panel_height = DEFAULT_PANEL_HEIGHT;
cfg->gap = DEFAULT_GAP;
strncpy(cfg->font_name, "fixed", sizeof(cfg->font_name) - 1);
cfg->mouse_distance_dpi = 0.0;
cfg->default_master_ratio = 0.55f;
cfg->default_master_count = 1;
@@ -158,6 +159,9 @@ static void handle_config_entry(const char *section, const char *key,
cfg->gap = (val >= 0 && val <= 100) ? val : DEFAULT_GAP;
} else if (strcmp(key, "font") == 0) {
strncpy(cfg->font_name, value, sizeof(cfg->font_name) - 1);
} else if (strcmp(key, "mouse_distance_dpi") == 0) {
double val = atof(value);
cfg->mouse_distance_dpi = (val > 0.0) ? val : 0.0;
}
} else if (strcmp(section, "layout") == 0) {
if (strcmp(key, "master_ratio") == 0) {