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.
This commit is contained in:
parent
a791787a38
commit
000c1a3b19
1 changed files with 7 additions and 2 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue