diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2024-04-20 06:18:41 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2024-04-20 06:26:44 +0000 |
| commit | 128c5c3efabc212f74a73ce256f8b35ee3ca49a5 (patch) | |
| tree | e95ec6abd9d6cd2782a82a18cc6728d8b8645bdf | |
| parent | char32: mbsntoc32() returns a size_t, not a char32_t (diff) | |
term: default to DPI 96, if the monitor's DPI is 0
This can happen in virtualized environments, or when running a nested
Wayland session.
| -rw-r--r-- | CHANGELOG.md | 6 | ||||
| -rw-r--r-- | terminal.c | 11 |
2 files changed, 13 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index feb48a3e..2851f7ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,12 @@ ### Deprecated ### Removed ### Fixed + +* Crash when zooming in or out, with `dpi-aware=yes`, and the + monitor's DPI is 0 (this is true for, for example, nested Wayland + sessions, or in virtualized environments). + + ### Security ### Contributors @@ -878,10 +878,13 @@ get_font_dpi(const struct terminal *term) mon = &tll_front(term->wl->monitors); } - if (term_fractional_scaling(term)) - return mon != NULL ? mon->dpi.physical : 96.; - else - return mon != NULL ? mon->dpi.scaled : 96.; + const float monitor_dpi = mon != NULL + ? term_fractional_scaling(term) + ? mon->dpi.physical + : mon->dpi.scaled + : 96.; + + return monitor_dpi > 0. ? monitor_dpi : 96.; } static enum fcft_subpixel |
