Gtk 4 has decided to blow up some people's world on HiDPI displays

July 5, 2024

Pavucontrol is my go-to GUI application for full volume control on my Fedora desktops. Recently (since updating to Fedora 40), pavucontrol started to choose giant font rendering, which made it more than a bit inconvenient to use. Today I attempted to diagnose this, without particular success, although I did find a fix, although it still leaves pavucontrol with weird rendering issues. But investigating things more deeply led me to discover just what was going on.

Pavucontrol is one of the applications that is now based on Gtk version 4 ('Gtk-4') instead of Gtk version 3 ('Gtk-3'). On Fedora 40 systems, you can investigate which RPM packages want each of these with:

$ rpm -q --whatrequires 'libgtk-4.so.1()(64bit)' | sort
[... a relatively short list ...]
$ rpm -q --whatrequires 'libgtk-3.so.0()(64bit)' | sort
[... a much longer list including eg Thunderbird ...]

I don't use a standard desktop environment like Gnome or KDE, so HiDPI presented me with some additional hassles that required me to, among other things, run an XSettings daemon and set some X resources to communicate my high DPI. Back in the days of Gtk-3, Gtk-based applications did not notice these settings, and required their own modifications; first I had to scale them up in order to get icons right, and then I had to scale Gtk-3 text back down again because the core text rendering that was used by Gtk-3 did recognize my high DPI. So I needed 'GDK_SCALE=2' and 'GDK_DPI_SCALE=0.5'.

In Gtk-4, it turns out that they removed support for GDK_DPI_SCALE but not GDK_SCALE (via this KDE bug report). This makes life decidedly awkward; I can choose between having decent sized icons and UI elements along with giant text, or reasonable text and tiny icons. Gtk-4 has a settings file (the personal one is normally ~/.config/gtk-4.0/settings.ini), but as explicitly documented it's mostly ignored if you have XSettings active, which I do because I need it for other things. The current Arch Linux wiki page section on HiDPI in X suggests that there is a way to override XSettings values for Gtk(-4?), but this doesn't work for test Gtk-4 applications for me.

At the moment I'm unsetting both environment variables in a cover script for pavucontrol, which is acceptable for it because it has relatively few graphical elements that are scaled down to tiny sizes for this. If and when applications with more graphical elements move to Gtk-4, this is going to be a real problem for me and I don't know how I'll solve it.

(When I started writing this entry I thought I had a mystery, but then more research turned up the direct answers, although not how I'm supposed to deal with this.)

Sidebar: The pavucontrol rendering problem I still have

No matter how wide I make the pavucontrol window, some text on the left side gets cut off. In the picture below, notice that the 'S' of 'Silence' isn't there.

The pavucontrol GUI showing output volume control, with a 'ilence' on the left side instead of 'Silence'

This doesn't happen in a test Cinnamon session in a Fedora 40 virtual machine I have handy, and I have no idea how one would go about figuring out what is wrong.

(This picture is with the sensible text sizes and thus small icons, and probably looks large in your browser because it comes from a HiDPI display.)

Written on 05 July 2024.
« Structured log formats are not really "plaintext" logs
"Out of band" network management is not trivial »

Page tools: View Source.
Search:
Login: Password:

Last modified: Fri Jul 5 23:00:24 2024
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.