From a14975cc4277418bb150cd7993ba6d7f67885d66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 27 Oct 2018 17:36:47 +0200 Subject: [PATCH] Platform: properly support the MAGNUM_DPI_SCALING environment variable. --- doc/changelog.dox | 10 +++++++++- .../Platform/Implementation/dpiScaling.hpp | 4 ++-- src/Magnum/Platform/Sdl2Application.h | 19 +++++++++++-------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index ae1a15044..bc8c7a861 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -36,7 +36,15 @@ See also: - @subpage changelog-extras "Extras changelog" - @subpage changelog-examples "Examples changelog" -@anchor changelog-latest +@section changelog-latest Changes since 2018.10 + +@subsection changelog-latest-bugfixes Bug fixes + +- Fixed @ref Platform::Sdl2Application and @ref Platform::GlfwApplication to + properly support the @cb{.sh} $MAGNUM_DPI_SCALING @ce environment variable + 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`. @section changelog-2018-10 2018.10 diff --git a/src/Magnum/Platform/Implementation/dpiScaling.hpp b/src/Magnum/Platform/Implementation/dpiScaling.hpp index 53ccd0fb1..2c91a59a8 100644 --- a/src/Magnum/Platform/Implementation/dpiScaling.hpp +++ b/src/Magnum/Platform/Implementation/dpiScaling.hpp @@ -46,8 +46,8 @@ namespace { inline Utility::Arguments windowScalingArguments() { Utility::Arguments args{"magnum"}; - args.addOption("dpi-scaling", "virtual") - .setFromEnvironment("dpi-scaling", "default") + args.addOption("dpi-scaling", "default") + .setFromEnvironment("dpi-scaling") #ifdef CORRADE_TARGET_APPLE .setHelp("dpi-scaling", "\n window DPI scaling", "default|framebuffer||\" \"") #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_ANDROID) diff --git a/src/Magnum/Platform/Sdl2Application.h b/src/Magnum/Platform/Sdl2Application.h index 084b95065..4962fe844 100644 --- a/src/Magnum/Platform/Sdl2Application.h +++ b/src/Magnum/Platform/Sdl2Application.h @@ -277,7 +277,8 @@ size and the framebuffer pixels will match display pixels 1:1. On displays that have different DPI, there are three possible scenarios, listed below. It's possible to fine tune the behavior either using extra parameters passed to @ref Configuration::setSize() or via the `--magnum-dpi-scaling` command-line -option. +option (or the equivalent @cb{.sh} $MAGNUM_DPI_SCALING @ce environment +variable). - Framebuffer DPI scaling. The window is created with exactly the requested size and all event coordinates are reported also relative to that size. @@ -285,7 +286,8 @@ option. supported on macOS and iOS. See @ref platforms-macos-hidpi for details how to enable it. Equivalent to passing @ref Configuration::DpiScalingPolicy::Framebuffer to - @ref Configuration::setSize() or `framebuffer` on command line. + @ref Configuration::setSize() or `framebuffer` via command line / + environment. - Virtual DPI scaling. Scales the window based on DPI scaling setting in the system. For example if a 800x600 window is requested and DPI scaling is set to 200%, the resulting window will have 1600x1200 pixels. The backing @@ -303,15 +305,16 @@ option. This is supported on Linux, Windows, all mobile platforms except iOS and Emscripten. Equivalent to passing @ref Configuration::DpiScalingPolicy::Physical to - @ref Configuration::setSize() or `physical` on command line. + @ref Configuration::setSize() or `physical` via command line / environment. Besides the above, it's possible to supply a custom DPI scaling value to @ref Configuration::setSize() or the `--magnum-dpi-scaling` command-line -option. Using `--magnum-dpi-scaling <number>` will make the scaling -same in both directions, with `--magnum-dpi-scaling " "` -the scaling will be different in each direction. On desktop systems custom DPI -scaling value will affect physical window size (with the content being scaled), -on mobile and web it will affect sharpness of the contents. +option (or environment variable). Using `--magnum-dpi-scaling <number>` +will make the scaling same in both directions, with +`--magnum-dpi-scaling " "` the scaling will be different +in each direction. On desktop systems custom DPI scaling value will affect +physical window size (with the content being scaled), on mobile and web it will +affect sharpness of the contents. The default is depending on the platform: