Qtile does not scale to the DPI set in config files
Hey! I'm using a Thinkpad X1 Carbon with 4k display. (Display size is 310 x 174 mm). I've set the dpi in all config files available to be 210. The only thing that does not respect my configure is Qtile bar, which is displaying following the default dpi (96x96). Is there any workaround when working on small displays and hidpi?
Any update on this? I'm running Qtile on a Surface Book 2 17".
Let's call the chief DPI officer. @tych0, any hint on this?
Good question. There's a PR available here:
https://github.com/qtile/qtile/pull/1229
The scaling works, the biggest problem really was that the bar was calculating clicks based on the 96 dpi size of the letters, and not the 210 (or whatever) it was.
But looking at it more closely, for e.g. groupbox, get_clicked_group() uses box_width(), which should be drawn using the DPI settings, so the widths should be right...
Maybe I'll play with the branch above more and see what's going on.
one year later I end up here having the same issue. could you actually get the scaling fixed with some workaround?
Feel free to adapt the above PR to your needs :-)
On Sat, Jan 16, 2021, at 8:32 AM, KIC wrote:
one year later I end up here having the same issue. could you actually get the scaling fixed with some workaround?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/qtile/qtile/issues/1494#issuecomment-761582307, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAF7VV4VHB5GZLKEAXOHIR3S2GWPNANCNFSM4JSKMDCQ.
the PR is quite old and is in conflict. However, I have tried to resolve the conflicts and added a test. Unfortunately, the test is failing and I have no idea why. Shouldn't I expect the window size on a double dpi display to be twice as big?
https://github.com/qtile/qtile/pull/2128
@manager_config_highdpi # dpi 150
def test_high_dpi_window_size(manager_highdpi):
manager_highdpi.test_xclock()
assert manager_highdpi.c.screen.info()["width"] == 2876
assert manager_highdpi.c.screen.info()["height"] == 1200
assert manager_highdpi.c.window.info()["width"] == 164 * 2
assert manager_highdpi.c.window.info()["height"] == 164 * 2
failes with:
test/test_highdpi.py:33 (test_high_dpi_window_size[ManagerConfig])
164 != 328
Yes, the tests probably need fixed when in high DPI mode.
That's my point. I am basically begging for help :-)
By debugging the test I know 150 dpi set in the resource manager but the desired result is not happening.
def configure_dpi(self):
...
self.root.set_property("RESOURCE_MANAGER", "Xft.dpi: %d\n" % float(dpi),
type="STRING", format=8,
mode=xcffib.xproto.PropMode.Append)
pangocffi.set_default_dpi(dpi)
Let's have the discussion in your PR -- I think I know what's going on.
Was this problem ever solved? I'm also trying to install qtile on a high res X1 carbon laptop and am having trouble making my bar a reasonable size.
FWIW, I fixed my problem by just scaling up my screen with the --scale 0.5x0.5 xrandr argument. I wanted the screen to be more zoomed in anyway.
@kovasap scale using xrandr makes all images blurry and unclear
For me that doesn't happen for some reason.
Here is what I've been using more recently to set my own monitor DPI: https://gist.github.com/tych0/a0e2d802b4bde6476997051c576d0ea6
That, run from my xsession in combination with some detection to determine what font size to use for the bar is enough for me to use heterogeneous-DPI monitors with X11. Of course, it is just using raw xcffib calls and is not really a great abstraction, but may be useful enough for someone to upstream something reasonable into qtile.
There seems to be a bug with how the status bar works, but all Wayland apps works fine.
Is perhaps the bottom application, the status bar, an X11 application?
@tych0 is there a solution for Wayland?
I'm not a user of the wayland backend, but my understanding was that it was mostly supported out of the box? We don't have DPI scaling for our widgets though, so maybe not.
Any solutions yet? Is there a way to at least change the font based on dpi detection? I am thinking of implementing something like this in my config, but I reckon someone tried that.
As a workaround for dynamic scaling, I've done the following:
import re
import subprocess
def get_dpi_from_xresources():
try:
# Use subprocess to run the 'xrdb -query' command and capture the output
xrdb_output = subprocess.check_output(["xrdb", "-query"], text=True)
# Use a regular expression to find the 'Xft.dpi' value
match = re.search(r"Xft\.dpi:\s*(\d+)", xrdb_output)
if match:
return float(match.group(1))
# Return None if 'Xft.dpi' is not found in the output
return 96
except Exception:
return 96
def set_font_size(dpi):
if dpi >= 192:
return 24
elif dpi >= 144:
return 20
elif dpi >= 120:
return 16
elif dpi >= 96:
return 10
elif dpi >= 72:
return 8
else:
return 6
After this, I am just loading this into the widgets and other places that require a font size. These are just random-ish values, but so far they look okay.
Make sure the Xft.dpy is set in .Xresources.