Gtk: Consider font dpi when calculating device scale factor

Gtk2 did not have a global window scaling setting (so the only way to
scale up widgets was with a custom theme).  However, it did allow font
scaling with gdk-xft-dpi (backed by XSetting Xft/DPI).

Gtk3 adds (non-fractional) global window scaling with
gdk-window-scaling-factor (XSetting Gdk/WindowScalingFactor).  To
ensure that fonts were not scaled up twice (once from
gdk-window-scaling-factor and once from gdk-xft-dpi), a new setting
was added in [1] that overrides gdk-xft-dpi: gdk-unscaled-dpi
(XSetting Gdk/UnscaledDPI).  gdk-xft-dpi was kept around for
compatibility with apps like Chromium that still need it.

When modifying these settings, an invariant should be maintained:
gdk-xft-dpi = gtk-window-scaling-factor * gdk-unscaled-dpi.  Chromium
should have been able to keep using gdk-xft-dpi, but this invariant is
violated when changing the settings using gnome-tweak-tool, where I
have gdk-window-scaling-factor = 2, gdk-unscaled-dpi = 98304, and
gdk-xft-dpi = 98304 (gdk-xft-dpi should be 196608).

[2] changed Gtk builds to use the window scaling factor, which is
incorrect because it did not consider font scaling, making fractional
scaling impossible.

This CL takes gdk-unscaled-dpi into the calculation as well, and
continues to fallback on using gdk-xft-dpi if the other variables are
unavailable, which can happen on Gtk2.



Cr-Commit-Position: refs/heads/master@{#473966}
1 file changed