←back to thread

Ancient X11 scaling technology

(flak.tedunangst.com)
283 points todsacerdoti | 5 comments | | HN request time: 0.001s | source
Show context
lelandbatey ◴[] No.44370477[source]
I admire your tenacity. I think folks say "X11 doesn't support DPI scaling" when they should say "most programs written against X11 to use official Xlib functionality don't understand scaling".

In the article, the author uses OpenGL to make sure that they're interacting with the screen at a "lower level" than plenty of apps that were written against X. But that's the rub, I think the author neatly sidestepped by mostly using stuff that's not in "vanilla" X11. In fact, the "standard" API of X via Xlib seems to only expose functions for working in raw pixels and raw pixel coordinates without any kind of scaling awareness. See XDrawLine as an example: https://www.x.org/releases/current/doc/man/man3/XDrawLine.3....

It seems to me that the RandR extension through xrandr is the thing providing the scaling info, not X11 itself. You can see that because the author calls `XRRGetScreenResourcesCurrent()` a function that's not a part of vanilla X11 (see list of X library functions here as example: https://www.x.org/releases/current/doc/man/man3/ )

Now, xrandr has been a thing since the early 2000s hence why xrandr is ubiquitous, but due to it's nature as an extension and plenty of existing code sitting around that's totally scale-unaware, I can see why folks believe X11 is scale unaware.

replies(2): >>44370524 #>>44379098 #
arp242 ◴[] No.44370524[source]
So on my laptop I've been doing:

  xrandr --output eDP --scale 0.8x0.8
For years and years, and I never really noticed any problems with it. Guess I don't run any "bad" scale-unaware programs? Or maybe I just never noticed(?)

At least from my perspective, for all practical purposes it seems to "just work".

replies(1): >>44370558 #
1. nixosbestos ◴[] No.44370558[source]
Good luck if you plug in an external monitor. (Not to speak of refresh rates)
replies(3): >>44371188 #>>44371612 #>>44372665 #
2. rwmj ◴[] No.44371188[source]
At the office I plug in a monitor over USB-C and that just works on my X11 laptop. If something in a browser on the monitor was too large or too small I'd just zoom in/out until it was fine.
3. arp242 ◴[] No.44371612[source]
I don't know about that; I use just one screen (laptop or HDMI, not both at the same time which is presumably what you're referring to) and it works for that. That's not really what the previous person was talking about either.
replies(1): >>44372088 #
4. 0x457 ◴[] No.44372088[source]
If you have two monitors with very different DPI, for example, I almost poke my eyes out when I tried 5k and 1440p together, you only have two choices: render for 5k and scale down to 1440p or render at 1440p and upscale to 5k. Well, you can also pick a middle ground that makes both monitors look blurry. Either way, at least one monitor will be _very_ blurry.
5. dlcarrier ◴[] No.44372665[source]

    --output eDP
This parameter specifies which display to scale, so only the built-in display will be scaled. Running xrandr without any parameters returns all available outputs, as well as the resolutions the currently connected displays support.