139 points · by woodruffw · 5y ago · 189 comments
That's 4 years. After those 4 years, there are people still trying to make their X11 square peg fit into the HiDPI round hole.
X11 is dead. Nobody is going to retrofit HiDPI into it as it is in Wayland. In another 4 years, it is still going to be as annoying as it is today to fix up X11 desktops and apps; maybe even more so.
My X11 setup also works perfectly fine back then, at 200%. Maybe even earlier, 2016 or so.
The caveat is, of course, 200%. Try 150% and it is really a pain in the ass.
The bad thing is it applies to all windows of that app, so you can't mix big and small vscode if put one window on laptop HD screen and one window on 4k external monitor.
I've also read the opposite opinion about macOS - namely, that it's the platform that does it best. I've ordered my first Mac (mini). It's arriving in 2 weeks. Will see then.
Overall, poor HiDPI support on Windows is one of the main reasons why I decided that I don't want to switch to Windows as my main driver and instead try macOS.
[1]: GNOME on the other hand is terrible. It's possible to get i3 to work with HiDPI, but there's no end to the work you need to perform to do that.
MacOS on the other hand sucks. Basically the recommendation is to run a lower and blurry resolution if you want bigger buttons and text...
At the same time, iOS has great scaling and text sizing options, and macOS’ interface is so abstract that it should be very easy to vectorize it, enabling seamless scaling to any size wanted.
Really baffling.
In comparison I've never had a problem on macos. All macos applications I run seem to render correctly no matter what resolution and dpi settings my various displays use. And I can move most applications between displays just fine - with no pop-in or strange behaviour as the resolution of the containing monitor changes. (Except for some web browsers - which detect the transition and re-render content at the new resolution).
On OSX in contrast, if you change the display resolution in System Preferences, most apps do not automatically adapt, with the result that you have to close their windows, then re-open them before your system is usable. And at non-integral scaling factors, everything is blurry at least on the non-retina displays I tried. In constrast, there is zero blurriness in the apps I just listed in Windows 10 regardless of which scale factor is chosen in the Settings app. On a 1080p monitor, the choices are 100%, 125%, 150% and 175%.
Gnome also lets you choose the scale factor in increments of 25% and in a few months after more apps have been adapted to work "directly" with Wayland (without the intervention of XWayland) promises to be as slick as Windows 10 currently is. (In fact, I personally prefer Gnome because on Windows changing the scale factor by 25% can result the stems and lines of the letters becoming abruptly twice as thick, but I vastly prefer either to MacOS's blurriness when the display is not being run at its native resolution, but again I had the luxury of being very choosy about which apps I used on Windows, relying mainly on a web browser and vscode.)
It does however run a tiny bit slower due to that non-integer retina scaling.
I’ve still not actually seen it for myself, and even having heard from multiple sources that yes, it really does work that way, I still find it hard to believe. It’s just… “here, let’s put higher-resolution displays in our laptops, but then scale things so badly that somehow it manages to be worse than a lower-resolution 1920×1080 panel would have been”. Snatching defeat from the jaws of victory.
I also find it utterly baffling.
X only allows setting a DPI per "display", but not per screen (multiple monitor setups where you can drag windows between screens use one X "display"). So you have to resort to these hacks.
[1] https://github.com/vincentbernat/awesome-configuration/blob/... [2] https://vincent.bernat.ch/en/blog/2018-4k-hidpi-dual-screen-...
A little off topic, but I've run into some weird issues with Display Port/Nvidia/Dell monitor where the monitor is not recognized on unplug/replug. In the past I know there were some issues with older Nvidia drivers and this particular monitor (P2715Q), though this seems like a weird problem that I've seen others have with different configurations online. It led to me needing a weird set of steps (I wrote about this in my Valve Index impressions [0]), using xrandr to add the display mode and switching to a virtual console too. I'm guessing this is mostly due to the older Dell monitor which has always been a bit wonky with Display Port. I assume things are better these days more broadly.
Relevant part of [0]:
xrandr --newmode "4K" 533.250 3840 3888 3920 4000 2160 2163 2168 2222 +hsync -vsync
xrandr --addmode DP-0 4K
xrandr --output DP-0 --mode 4K
# switch to virtual terminal, i.e. Ctrl-Alt-F2
# switch to DisplayPort input on monitor which should display the terminal
env DISPLAY=:0 xset dpms force off; sleep 5; env DISPLAY=:0 xset dpms force on
# switch back to X, i.e. Ctrl-Alt-F7
The modeline to add can be found ahead of time with xrandr --verbose or using a tool like cvt or gtf (see the Arch wiki). Sometimes, though, I just need to power cycle the monitor or unplug and replug some cables. I hope this is just this older hardware, and probably solved, like everything else here, with a new GPU that has more DisplayPort outputs.[0] https://boilingsteam.com/the-valve-index-on-linux-on-a-min-s...
However, I recently bought a ThinkPad T14 with a 1080p screen. With 100% scaling, the fonts and widgets are too small. The ideal scaling seems to be 125% or 150%. GNOME has experimental support for fractional scaling. This works generally ok for Wayland applications, but windows of X11 applications are incredibly blurry both on the laptop display with 150% scaling and the external screen with 200% screen. I think they are rendered at 100% and then scaled up. There are various workarounds for X11 applications, but it seems that e.g. none of the workaround really works with e.g. JetBrains IDEs (there are some bug reports about it).
Windows 10, on the other hand, handles fractional scaling and per-screen scaling just fine. It's frustrating, because I highly prefer GNOME and Linux and if all applications supported Wayland, there wouldn't be any major problems.
The ideal would be 3200x2000, but sadly, nobody sells such laptops anymore. Everyone jumps from WQHD to 4k. With 4k, you have exactly the same problem, except for 125% you need 250%.
Its because everyone having issues is using X and likely 2 monitors with different dpis. On wayland its pretty much flawless unless you use 2 monitors at different scales and load an X application.
Agree 100%, this is the only issue I ran into using Wayland (Sway) with different DPI monitors.
I only want to stress that the impact of this issue is very limited—at least for me. Most of the apps that I use run natively on Wayland and scale perfectly: Firefox (with some extra setup), Telegram Desktop, Alacritty, all GTK and KDE apps.
The apps that do get blurry are the ones that are made by big companies for which Linux experience is not the first priority (thus they don't care about native Wayland support). Zoom, Chromium, Google Earth, Discord, Steam, Skype. I don't use them much, and when I do I try to keep them on my big (non-scaled) monitor, and it works fine.
Once I upgraded to a 4k it's a great setup. I actually have dual 4k monitors now and that xps can handle it easily. No software issues either. The most I've had to do was adjust the zoo launcher to be hidpi
But I find 1x scaling to be too small to enjoy on the QHD screen. Multiple integer scale factors are possible but it is a bit complex and when I did it machine was prone to crash...
That said I still love it.
Well, except for an outstanding bug where after I log in, I get a duplicate, stationary mouse cursor appearing somewhere on the screen that just hovers over any open windows. Its annoying and weird.
They did, its called wayland. If you want to use a legacy tool you shouldn't expect it to work as nice as the current generation software.
I'm not using the "current generation" because it doesn't work as nice as the "legacy" software. Have y'all figured out how to do screen sharing without per-compositor hacks yet?
Like the OP say, if you want HiDPI fractional scaling that’s a solved problem on Wayland. If you want to stick with X11, then that’s never going to work great
If you insist on your favorite x11 window manager, the integration is on you. No point in complaining then, it is self-inflicted pain.
As much as i like the concept of Wayland, until it's a one click always works without any caveats option in Ubuntu it essentially doesn't exist. Ubuntu 20.04, the latest of the most popular distributions, does not have wayland enabled by default. They actively discourages you from trying it if you have Nvidia, which again is the most popular gfx card - not sure if one is supposed skip the proprietary drivers or not with Wayland but on X11 using Nouveau is not a pleasant experience.
Even worse is when you connect an external monitor which is not HiDPI and now everything is bigger than usual.
Instead scale the whole display and this works perfectly. I have explained it here: https://np.reddit.com/r/linuxquestions/comments/4c2o4p/what_... (Except one hiccup, but its way better than tuning inidividual knobs)
I have added the command to /etc/X11/xinit/xinitrc so it scales automatically when I login:
xrandr --output eDP1 --scale 0.60x0.60
This has been a real bugbear for me. I'm a big fan of small sharp bitmap terminal fonts, but as my new laptop is now the same resolution as my external monitor I have a choice between comically small on the laptop display or comically huge on the monitor.
Wayland just punts on the issue by removing the compositor from any decision involving scaling. The "Wayland Way" is for the compoisitor to relay information (monitor-reported scale, etc) to the client, and have the client figure out how to scale itself correctly.
Unfortunately this means that these HiDPI bugs have to be fixed over and over in myriad apps and toolkits, and software (cough cough chromium) that is so complicated that it cannot use a toolkit.
Some compositors like sway will let you do in-compositor scaling, but this is admittedly a kludge: it produces blurry scaled-up output instead of rendering at the right resolution in the first place. The sway authors acknowledge this; the feature is only there as a "better than nothing" workaround.
Xresources:
Xft.dpi:120
st.font: monospace:size=14
xsession: # haven't had time to dig into this, some systems need
# DPI set twice
xSetDpi () { xrandr --dpi "$1"; xrandr --dpi "$1"; }
That function is called in a case statement for other machine-specific startup config, but it's just a matter of xSetDpi 144;.emacs.d/init.el:
(set-face-attribute 'default nil :height xxx)
Again this is per-host, but it's a simple COND expression.qutebrowser/config.py:
# even with DPI set, I typically find web text too small
c.zoom.default = '175%'
I promise you that this does not feel like any significant effort for me. It's ~10 lines across a few config files, each of which I would be maintaining anyway - none of these configs were born for the express purpose of handling DPI or zoom or anything like that.I value having a system that is configured exactly to my preferences. I recognize that having multiple configs is a turnoff for some. I can't debate personal preference.
I have spent much more time trying to get something like Gnome to behave in a way I want than I have on all of my current config. XFCE is a pretty good experience for a DE and configuring scaling through system settings.
Machines:
1. 11" HD, OpenBSD current
2. 12" FHD, Artix Linux
3. 2x27" WQHD, Artix Linux
GTK2 apps do not support HiDPI correctly. oomox (and similar) can be used to generate a scaled GTK2 theme, but it won't solve all your problems.
GTK3 supports HiDPI well. If you use Gnome, Xfce and others, you can configure this via the preferences UI. Otherwise, add this to your .profile file:
export GDK_SCALE=2
export GDK_DPI_SCALE=0.5
Many Java apps can be scaled by adding an argument... java -Dsun.java2d.uiScale=2
For Qt you can add this to your .profile file: export QT_AUTO_SCREEN_SCALE_FACTOR=0
export QT_SCALE_FACTOR=2
# For theming, requires qt5ct
export QT_QPA_PLATFORMTHEME=qt5ct
For Spotify... I use ncspot for listening, and the web version to manage my playlists (although you can also management with ncspot). ncspot is a keyboard friendly, lightweight terminal client. https://github.com/hrkfdn/ncspot
I use FreeOffice as office suite, you can configure HiDPI through the menus and works perfectly. Same with Steam.Every solution I've found so far (including the QT/GTK environment variables for overriding DPI) ends up instead causing scaling during compositing, rather than getting the apps to rasterize their fonts at the correct size in the first place. The worst offenders are anything derived from Chromium (i.e. qutebrowser, who say the problem is a QtWebEngine bug that they can't fix).
I'm using sway, but almost all the Wayland compositors lack this override-the-monitor-reported-DPI functionality, because (for good reason) their philosophy is to securely multiplex the hardware, not abstract it away. They just pass through whatever values the monitor reports, to the client.
IMHO this does not make sense for physical pixel size, because it disregards the physical distance between the user's face and the pixels. What you really want to size your fonts based on is the number of arc-radians (or arc-degrees) per pixel, measured at the user's eyeball. In order to compute that you need to know both the physical pixel size (which can be queried from the device) and the physical eyeball-screen distance (which will need to be user-configurable).
The brute-force way to alter everything your monitor reports, is to dump its EDID data, patch it (there are programs for this, or you can resort to a hex editor and the EDID spec), and then tell your kernel to load that patched EDID in place of the real EDID when it recognizes your monitor.
On Linux, that's apparently accomplished by plopping the patched EDID file into /lib/firmware: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/lin...
(I've never actually done this with Linux, but I've done it in macOS on a Hackintosh, because macOS frequently thinks televisions connected over HDMI should be fed YUV instead of sRGB. You can patch the EDID to force macOS to treat the TV as a monitor.)
In X11, you can do it with xrandr --fbmm. Technically you can also set this information per-monitor but I don't think a command line option was ever added for it.
Yeah, that's basically what I want, but for sway.
> Wayland applications should not be using that information to decide scaling. They should be using the wl_output.scale.
Maybe so, but the physical size is definitely exposed to the clients via the wayland protocol (see below). I'm pretty sure that the QT toolkit and Chromium both use the reported values.
<event name="geometry">
<description summary="properties of the output">
The geometry event describes geometric properties of the output.
The event is sent when binding to the output object and whenever
any of the properties change.
The physical size can be set to zero if it doesn't make sense for this
output (e.g. for projectors or virtual outputs).
</description>
<arg name="x" type="int" />
<arg name="y" type="int" />
<arg name="physical_width" type="int" />
<arg name="physical_height" type="int" />
<arg name="subpixel" type="int" enum="subpixel" />
<arg name="make" type="string" />
<arg name="model" type="string" />
<arg name="transform" type="int" enum="transform" />
</event>
I will probably end up hacking it into sway, like I've done with other things.It's just that the swaywm/libwlroots codebase is so utterly illegible. "wlroots is largely documented through comments in the headers. Read 'em." Yeah, those headers with no comments anywhere, egregious amounts of boilerplate code (because C), and naming conventions that take weeks to learn. Argh. I've spent entire days trying to figure out "how to I get a sway_foo pointer from a wlr_foo pointer". It's madness. There's so much typecasting going (with totally undocumented rules for when said typecasts are safe) on that you can't even use the compiler-visible types as a guide for these kinds of questions.
I've found that 2k (2560x) displays at 27" give me great real estate without any need to scale.
The relatively common use of "2k" to mean 2560x1440 has always struck me as confusing though, since it's not half as wide as 4k. Words mean whatever people agree they mean, but I feel like "2k" is too ambiguous.
From an ergonomics standpoint (i.e. the health of your neck), the upper edge of your monitor shouldn't be higher than your eye level. Looking straight or looking down is fine.
Thus the monitor on the left is probably not very ergonomic.
Then I realized: I spend most of my time staring at the bottom half, to bottom edge, of the screen. Typing in a terminal, adding functions at the bottom of a file, etc. I moved my monitor such that my eyes are almost dead-center, vertically, and haven't had any issues since, neither neck nor shoulders. I kept the improved posture too, so I'm sure that ultimately helped too.
I'm sure the recommended is recommended for a reason, and works for most, but hopefully my experience is useful to some.
I find having a vertical 24" monitor to be super useful, especially for reading typical PDF files as an entire page fits nicely on the screen.
My vertical monitor is a bit closer to the desk, and the horizontal monitor is much higher than yours, about 7.5" above the desk. The bottom edges are not aligned; the vertical monitor bottom edge is about 5" below the bottom of the horizontal monitor, and its top edge is about 3" above the top of the horizontal monitor.
The top of horizontal monitor is just below my eye height. So the top of the vertical one is a couple of inches above that, but this is not a problem as I don't spend much time looking at the very top of that monitor.
Each monitor is tilted separately. The horizontal one is tilted back only slightly; the vertical one tilted more. So the center of each monitor is perpendicular to my line of sight.
At the moment I'm using the two monitors with a Linux desktop, but sometimes I connect them both to a ThinkPad for a three-monitor setup with the ThinkPad's display and keyboard. When I do this, I raise the horizontal monitor up another inch so the ThinkPad display tucks in underneath it.
With your horizontal monitor sitting so close to the desk, I have to wonder if your seating position may be too low? Are your forearms horizontal when typing? (Forgive me if I'm being nosy or presumptuous, just curious.)
One related tip for anyone reading this, regardless of your monitor arrangement: if you wear glasses, do not use progressive lenses at your computer. Instead, get a pair of single vision lenses with a fairly tall aspect ratio so they let you see the entire screen(s) without tilting your head back. Don't ask your optometrist for a "reading" prescription - that tends to be about a 16" distance, and your monitors are probably farther from your eyes than that. Measure the distance from your eyes to the monitors and get single vision lenses made for that distance.
They're 24", like yours. It sounds like our setups are actually nearly identical: the top of my horizontal monitor is also just below my eye height, and I spend most of my time looking at the middle of the vertical one. I should probably move them around a bit so I can actually look at the vertical one without turning my head, though.
> With your horizontal monitor sitting so close to the desk, I have to wonder if your seating position may be too low? Are your forearms horizontal when typing? (Forgive me if I'm being nosy or presumptuous, just curious.)
I appreciate it! I think my seating is right, at least based on what I was taught about ergonomics -- my forearms are horizontal and I don't have to pivot my wrists up or down while typing or moving my mouse.
The only app that didn't pick up my DPI settings on Linux was Spotify, but all web-ish apps support ctrl +/-...which honestly strikes me as a big usability win over native toolkits.
I actually found my 5K screen more enjoyable under Linux than macOS, because the performance of JetBrains IDEs on Retina Macs seems to flip-flop between okay and abysmal every year.
Mixed-DPI setups are where macOS is truly superior.
Apple tried true resolution independence in the early 2000s and it didn't work out. 2x and 3x scaling proved to be a much better solution.
Since then, however, Apple's UI has (regrettably) become less about pixel-perfect bitmaps and more about black typography on white roundrects, and almost all Macs run at a scaled resolution by default, which is then typically used to display web-based apps that support fractional scaling.
I really think that Windows' approach has aged much better. Kudos to Microsoft. We could have our cake and eat it too if Apple sold Macs with slightly higher-resolution displays, and also a 5K 27" display because other manufacturers can't be bothered.
Yet, there are cries from the Internets, that it is not pixel perfect and other solution (Windows/Qt/Android-like) should be used.
[1] Mostly that you can't update client side libs like you can in Mac and Windows land and be done; there will be always some legacy X11 client that will connect directly to display server and ignore your modifications. On mac and windows, apps cannot talk directly to display server, the protocol is not public.
If you want to find the correct dimensions for you monitor, this page might help you:
I was actually surprised when using a 2020 Mac that macOS doesn't actually support scaling on external displays. It seems that Linux/Wayland is on the lead here.
If you, like me, are blind as a bat may I recommend `Xcursor.size` as well.
Anyone know how to get mouse cursor comet trails in Linux?
In my case, my time isn’t worthless but I do enjoy configuring my system. The tweaks shown in those blog post took me maybe half a day; I haven’t needed to make any significant changes since.
Even X11 applications work reasonably well on XWayland on e.g. GNOME, as long as all screens use 100% or 200% scaling. Unfortunately, with fractional scaling things break down with X11 applications.