Browse Source

Platform: don't assert on X11 DEs that don't have RESOURCE_MANAGER.

pull/297/head
Vladimír Vondruš 8 years ago
parent
commit
89f7a5ee75
  1. 3
      doc/changelog.dox
  2. 25
      src/Magnum/Platform/Implementation/dpiScaling.hpp

3
doc/changelog.dox

@ -45,6 +45,9 @@ See also:
as an alternative to `--magnum-dpi-scaling` command-line parameter. It was
also not documented anywhere. Besides that, the default `--magnum-dpi-scaling`
value should have been `default` as documented, not `virtual`.
- Don't assert in DPI scaling detection in @ref Platform::Sdl2Application and
@ref Platform::GlfwApplication on X11 DEs that don't create any
`RESOURCE_MANAGER` (see [mosra/magnum#290](https://github.com/mosra/magnum/issues/290))
@section changelog-2018-10 2018.10

25
src/Magnum/Platform/Implementation/dpiScaling.hpp

@ -102,18 +102,19 @@ inline Float x11DpiScaling() {
Containers::ScopedExit closeDisplay{display, xCloseDisplay};
const char* rms = xResourceManagerString(display);
CORRADE_INTERNAL_ASSERT(rms);
XrmDatabase db = xrmGetStringDatabase(rms);
CORRADE_INTERNAL_ASSERT(db);
Containers::ScopedExit closeDb{db, xrmDestroyDatabase};
XrmValue value;
char* type{};
if(xrmGetResource(db, "Xft.dpi", "Xft.Dpi", &type, &value)) {
if(type && strcmp(type, "String") == 0) {
const float scaling = std::stof(value.addr)/96.0f;
CORRADE_INTERNAL_ASSERT(scaling);
return scaling;
if(rms) {
XrmDatabase db = xrmGetStringDatabase(rms);
CORRADE_INTERNAL_ASSERT(db);
Containers::ScopedExit closeDb{db, xrmDestroyDatabase};
XrmValue value;
char* type{};
if(xrmGetResource(db, "Xft.dpi", "Xft.Dpi", &type, &value)) {
if(type && strcmp(type, "String") == 0) {
const float scaling = std::stof(value.addr)/96.0f;
CORRADE_INTERNAL_ASSERT(scaling);
return scaling;
}
}
}

Loading…
Cancel
Save