From 832d9e1bed83a69324180a6e45b02586b9bdfcd2 Mon Sep 17 00:00:00 2001 From: toluschr Date: Tue, 24 May 2022 11:09:58 +0200 Subject: [PATCH] Fix zathura not rendering on hidpi displays Related to https://gitlab.gnome.org/GNOME/gtk/-/issues/3115. Ideally, GNOME could fix their library to return 0 instead of 1. --- zathura/zathura.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zathura/zathura.c b/zathura/zathura.c index e1ed652..244169f 100644 --- a/zathura/zathura.c +++ b/zathura/zathura.c @@ -173,10 +173,12 @@ zathura_update_view_ppi(zathura_t* zathura) GdkRectangle monitor_geom; gdk_monitor_get_geometry(monitor, &monitor_geom); - /* calculate ppi, knowing that 1 inch = 25.4 mm */ - if (width_mm == 0) { + /* Due to a bug in Gtk, width is sometimes incorrectly reported to be 1mm + * see https://gitlab.gnome.org/GNOME/gtk/issues/3115 for details */ + if (width_mm <= 1) { girara_debug("cannot calculate PPI: monitor has zero width"); } else { + /* calculate ppi, knowing that 1 inch = 25.4 mm */ ppi = monitor_geom.width * 25.4 / width_mm; }