diff options
author | Gabriel Díaz <gdiaz@qswarm.com> | 2018-11-14 06:19:29 +0100 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2018-11-14 00:19:29 -0500 |
commit | 000c1a3b19a8d3f8bbaefba84131995cb62c889f (patch) | |
tree | a6dfaa9747977a7c9bb574cedb3b8e39c6335a2a /src/cmd/devdraw | |
parent | a791787a384745b90fa0eb704cd9cbbe8c758684 (diff) | |
download | plan9port-000c1a3b19a8d3f8bbaefba84131995cb62c889f.tar.gz plan9port-000c1a3b19a8d3f8bbaefba84131995cb62c889f.tar.bz2 plan9port-000c1a3b19a8d3f8bbaefba84131995cb62c889f.zip |
devdraw: set displaydpi on devdraw x11 attach (#178)
See https://plan9port-review.googlesource.com/c/plan9/+/1470
for discussion of the approach, especially Michael Stapleberg's comment:
Note that chromium, firefox and others have tried this and then switched to using the Xft.dpi X resource, see e.g. https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/ui/libgtk2ui/gtk2_ui.cc and especially http://sources.debian.net/src/gnome-settings-daemon/3.18.2-1/plugins/xsettings/gsd-xsettings-manager.c/?hl=824#L80 for some anecdata about why this approach doesn’t work out.
The Xft.dpi resource is being set accurately by desktop environments (GNOME, KDE, …) and can easily be changed by users of niche window managers by editing ~/.Xresources.
I suggest we check only Xft.dpi, without considering the DPI environment variable or the monitor width/height.
Diffstat (limited to 'src/cmd/devdraw')
-rw-r--r-- | src/cmd/devdraw/x11-init.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/cmd/devdraw/x11-init.c b/src/cmd/devdraw/x11-init.c index 5363fb74..f09963dc 100644 --- a/src/cmd/devdraw/x11-init.c +++ b/src/cmd/devdraw/x11-init.c @@ -208,9 +208,9 @@ _xattach(char *label, char *winsize) * Parse the various X resources. Thanks to Peter Canning. */ char *screen_resources, *display_resources, *geom, - *geomrestype, *home, *file; + *geomrestype, *home, *file, *dpitype; XrmDatabase database; - XrmValue geomres; + XrmValue geomres, dpires; database = XrmGetDatabase(_x.display); screen_resources = XScreenResourceString(xscreen); @@ -230,6 +230,11 @@ _xattach(char *label, char *winsize) }else XrmCombineDatabase(XrmGetStringDatabase(display_resources), &database, False); + if (XrmGetResource(database, "Xft.dpi", "String", &dpitype, &dpires) == True) { + if (dpires.addr) { + displaydpi=atoi(dpires.addr); + } + } geom = smprint("%s.geometry", label); if(geom && XrmGetResource(database, geom, nil, &geomrestype, &geomres)) mask = XParseGeometry(geomres.addr, &x, &y, (uint*)&width, (uint*)&height); |