From 42c6af091440e89be9c0d8895a1c5ff1caac5427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 4 Nov 2022 17:45:43 +0100 Subject: [PATCH] =?UTF-8?q?wayland:=20force=20monitor=20DPI=20to=2096=20wh?= =?UTF-8?q?en=20it=E2=80=99s=20unreasonably=20high?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If an output has a bogus physical width or height, the DPI can become so high that the cell width/height is too large for pixman_image_fill_rectangles(), resulting in a crash in pixman_fill(). Since it doesn’t make any sense to use a DPI that is obviously bogus, don’t. Force it 96 instead. --- CHANGELOG.md | 1 + wayland.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c41f21a..f4089b37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,7 @@ ("permanently reset") instead of `2` ("reset") for DEC private modes that are known but unsupported. * Set `PWD` environment variable in the slave process ([#1179][1179]). +* DPI is now forced to 96 when found to be unreasonably high. [1166]: https://codeberg.org/dnkl/foot/issues/1166 [1179]: https://codeberg.org/dnkl/foot/issues/1179 diff --git a/wayland.c b/wayland.c index 974dfb39..e48d59aa 100644 --- a/wayland.c +++ b/wayland.c @@ -409,6 +409,14 @@ output_update_ppi(struct monitor *mon) 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