diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2022-11-22 08:34:53 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2022-11-22 08:34:53 +0000 |
| commit | 4d2b8a993f565061386599a09f25358274700897 (patch) | |
| tree | 42cdaf7055e212bfcfab4c432efaf6f3f3ccd64a /wayland.c | |
| parent | added modus themes (diff) | |
| parent | wayland: force monitor DPI to 96 when it’s unreasonably high (diff) | |
Merge branch 'fp-calc-dpi'
Closes #1209
Diffstat (limited to 'wayland.c')
| -rw-r--r-- | wayland.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -370,8 +370,8 @@ output_update_ppi(struct monitor *mon) if (mon->dim.mm.width <= 0 || mon->dim.mm.height <= 0) return; - int x_inches = mon->dim.mm.width * 0.03937008; - int y_inches = mon->dim.mm.height * 0.03937008; + double x_inches = mon->dim.mm.width * 0.03937008; + double y_inches = mon->dim.mm.height * 0.03937008; mon->ppi.real.x = mon->dim.px_real.width / x_inches; mon->ppi.real.y = mon->dim.px_real.height / y_inches; @@ -407,8 +407,16 @@ output_update_ppi(struct monitor *mon) mon->ppi.scaled.x = scaled_width / x_inches; mon->ppi.scaled.y = scaled_height / y_inches; - float px_diag = sqrt(pow(scaled_width, 2) + pow(scaled_height, 2)); + double px_diag = sqrt(pow(scaled_width, 2) + pow(scaled_height, 2)); mon->dpi = px_diag / mon->inch * mon->scale; + + if (mon->dpi > 1000) { + if (mon->name != NULL) { + LOG_WARN("%s: DPI=%f is unreasonable, using 96 instead", + mon->name, mon->dpi); + } + mon->dpi = 96; + } } static void |
