home / blog / podcasts / videos / notes / photos / about / more

Scaling on Linux

still very frustrating

Posted by Jeena

HIDPI scaling on Linux is still a very frustrating experience. It seems to work nice if you have either only one screen or all of the screen having the same scaling factor. But sadly this is not what I have in my setup.

After moving to Korea I started working from home on my Dell XPS 13 laptop, which has a 4k screen, but the screen estate on it is very limited.

I mentioned this to my girlfriend and she decided to suprise me with a aditional big screen (for some reason in Korea the companies don't give you hardware to work on if you work from home). But sadly she didn't really know about all the limitations in Linux and that you have to do some research and to buy the correct hardware and she bought a 2k monitor instead of a 4k. This in itself would not be a big problem, if it weren't for how Linux handles scaling.

I'm running GNOME with Wayland and am able to set different scaling on the two screens, so I set 2x on the hidpi laptop one and 1x on the external. And for all GTK apps this works fine, it doesn't matter where the window appears when it starts, it gets rescaled properly when I move it between the two screens (ok there is some weirdness when you're moving the window but it's very short so I don't really care, this will get fixed some day).

But the problems start when I start using QT applications like KeePassXC or FeedTheMonkey. Because then the app is correct on the main screen but when I move it to the other screen then it does not adapt to the other screens scaling factor but just stays like it was and is either double the size or one quater of the size.

This is the default behaviour for Qt applications on GNOME because they per default run under XWayland and I can't figure out how to make them resize when I move them between the screens under XWayland. From what I could find out this is the latest atempt to keep the discussion going: Draft: xwayland: Multi DPI support via global factor rescaling - updated using properties

On GNOME XWayland for Ot applications is the default because QtWayland seems to have some problems. You can still try to force it by using QT_QPA_PLATFORM=wayland which I did and to my suprise the rescaling between the different screens works like a charm!

There is one problem though, it does use QTs own window decorations and looks terrible on both screens. Depending on the applications sometimes it at least changes to the correct dark/light theme. But it has it's own buttons top right and does not draw the shaddow like normal GNOME apps have it, so it sits flat on top of other windows and looks very weird.

I tried to install qgnomeplatform-qt6 and force it with QT_QPA_PLATFORMTHEME=gnome but it didn't do anything. I also tried QT_QPA_PLATFORMTHEME=qt5ct after installing it, also no change.

Now I can either live with 1/4 size windows when I move them to my laptop screen, or very ugly window decorations which don't fit into the overall picture. Very frustrating.

Screenshot of QT app window with 1/4 size

Screenshot of QT app window with white decorations

[Update 2022-11-04]

Someone reached out to me after reading this article and pointed out that KeePassXC is a Qt5 application but I only installed qgnomeplatform-qt6 and this probably was the reason why both KeePassXC and FeedTheMonkey don't use the QT_QPA_PLATFORMTHEME=gnome variable correctly.

And after installing the correct version it works! (almost)

Screenshot of QT app window with correct decorations

It's good enough for me so that I will use it like this, but it's not perfect:

There are some other apps left which still didn't quite work until I forced them to run in Wayland:

To get Firefox working I had to add export GDK_BACKEND=wayland.

For Chromium I have to start it with chromium --enable-features=UseOzonePlatform --ozone-platform=wayland.

For electron apps I had to add element-desktop --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-features=WaylandWindowDecorations.

So far I think I got everything working with wayland after forcing it, at least at a first glance. I suspect I will find annoying bugs in the apps when I use them under wayland, but that's for later. For now, great success!

Have you written a response? Let me know the URL:

There's also indie comments (webmentions) support.