Hacker News new | ask | show | jobs
by orangeboats 626 days ago
You can have displays with different DPI on Linux and achieve good font rendering. But it requires the latest versions of your favourite DE (like GNOME 45+ and KDE 6.x) and you'd need to give up X11 (which does not support mixed DPI very well).
1 comments

X11 handles mixed DPI fine. Monitor configuration GUI for DE don't support the required option however both X and nvidia-settings do
X11 quite literally doesn't have the notion of DPI, there is only a single coordinate space. Xrandr is per-output and not per-window.
I'm literally sitting at a station with 3 monitors 2 high DPI and 1 low DPI wherein UI elements of a window moved from one monitor to the other are identically sized and this was the case when all 3 monitors were different sizes and DPI as well.

In this case the UI is scaled up by an integer factor on all screens so as to look nice on the highest DPI screen. It is scaled down from the higher resolution by a decimal factor that could be but needn't be an integer. If the factor is proportional to the difference in DPI the result is UI elements being sized precisely the same size across different size and dpi monitors.

All monitors share a singular scaling factor and DPI. Apps thus need to support high DPI but needn't do anything smart to support scaling because it happens outside of the apps remit.

This can be achieved again with xrandr --scale OR in the nvidia-settings GUI by setting viewport in to a higher resolution than viewport out. No the result isn't blurry.

First thing first, the X11 protocol is not aware of DPI. Period. And that has implications. You can apply all sorts of hackish solutions on top of it but (1) the solutions will most likely be out-of-band (not pure X11) and involve DBus/envvars/Xft.dpi, and (2) per-output.

Out-of-band solutions are effectively bandaids and they unnecessarily increase development difficulty of GUI programs on Linux, since developers now have to be aware of the various side channels (fragmentation!) that communicate the DPI scale.

This is why SDL2 for the longest period did not support HiDPI on X11, but does on Wayland, MacOS, and Windows. A COSMIC dev just recently made a complaint about XSettings too! [0] You can't just ignore those problems, "Linux is hard to develop for, blah blah fragmentation blah blah" I am sure you have heard of.

Another thing. Per-output HiDPI is fine when all your programs support high DPI, but it's unworkable if you want to mix LoDPI and HiDPI applications in a single screen, i.e. if an application has better user experience if it is upscaled and blurry (!), you are SOL unless you want to apply scaling to your entire desktop.

You also lose the opportunity to implement some neat features like temporarily scaling up a window if it is being magnified or screenshot. (The idea's been floating about in the KDE community)

Finally, we can argue for days, but the HiDPI page on Arch wiki already says a lot when a good 90% of the article is about acheiving good DPI scaling on X11 [1]. Even the Wayland sections have an XWayland subsection in them...

[0]: https://tech.lgbt/@drakulix/113029499719670970

[1]: https://wiki.archlinux.org/title/HiDPI#Xorg

Scaling is a built in feature of X for over 20 years intended for this use case no bandaids of any sort or awareness by the applications of differing DPI.

From the perspective of apps there is only one DPI with all scaling down handled by X at a layer below the apps level. There really aren't any lodpi apps on a modern X system only Wayland has issues scaling X apps correctly. Gtk Apps not updated this decade can handle scaling up by integer factors and because X scales the lower dpi monitor down to the appropriate size the app doesn't need to handle anything else.

Its very odd for folks to argue that my mixed DPI system using only basic boring old xorg.conf somehow doesn't exist. I mean would you like to come to my apartment and open a few different apps?

Its in a way ironic that between pure X, pure Wayland, and Wayland + xwayland only the last can't handle mixed DPI.

> There really aren't any lodpi apps on a modern X system only Wayland has issues scaling X apps correctly.

The problem starts at XWayland, not Wayland. And XWayland is just your typical X server with all its X intricacies.

Only if we can somehow communicate our intended scale to the X clients through XWayland... oh, we can't!

> Its very odd for folks to argue that my mixed DPI system using only basic boring old xorg.conf somehow doesn't exist.

You keep on confusing per-window and per-output DPI. I can only assume you are feigning ignorance at this point. Good luck with attitude.

I still have a couple GTK2 apps installed that doesn't support HiDPI, those are best used upscaled but... they can't. Those apps are unable to communicate to the server they are rendered at 1x (rather, the server doesn't have the notion of per-window scales at all).