diff --git a/doc/changelog.dox b/doc/changelog.dox index 3f0e1bdb8..c19f96dd4 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -101,6 +101,9 @@ See also: - @ref Platform::Sdl2Application::viewportEvent() gets properly fired also when window size changes programmatically (such as through @ref Platform::Sdl2Application::setMinWindowSize() "setMinWindowSize()") +- @ref Platform::GlfwApplication::setMinWindowSize() / + @ref Platform::GlfwApplication::setMaxWindowSize() and equivalent APIs in + @ref Platform::Sdl2Application now correctly take DPI scaling into account - The @ref Primitives::cylinderSolid() and @ref Primitives::coneSolid() primitives were missing a face when both caps and texture coordinates were enabled (see [mosra/magnum#386](https://github.com/mosra/magnum/issues/386)) @@ -122,6 +125,11 @@ See also: @ref Animation library was changed to allow mutable access to the keys & values it references. Existing code needs to be changed to say @cpp TrackView @ce instead of @cpp TrackView @ce. +- @ref Platform::GlfwApplication::setMinWindowSize() / + @ref Platform::GlfwApplication::setMaxWindowSize() and equivalent APIs in + @ref Platform::Sdl2Application now premultiply the value with + @ref Platform::GlfwApplication::dpiScaling() "dpiScaling()" to work + independently on display DPI. This might break existing uses. @subsection changelog-latest-documentation Documentation diff --git a/src/Magnum/Platform/GlfwApplication.cpp b/src/Magnum/Platform/GlfwApplication.cpp index f4be6fd75..f53a31a9e 100644 --- a/src/Magnum/Platform/GlfwApplication.cpp +++ b/src/Magnum/Platform/GlfwApplication.cpp @@ -588,15 +588,17 @@ Vector2i GlfwApplication::windowSize() const { void GlfwApplication::setMinWindowSize(const Vector2i& size) { CORRADE_ASSERT(_window, "Platform::GlfwApplication::setMinWindowSize(): no window opened", ); - glfwSetWindowSizeLimits(_window, size.x(), size.y(), _maxWindowSize.x(), _maxWindowSize.y()); - _minWindowSize = size; + const Vector2i newSize = _dpiScaling*size; + glfwSetWindowSizeLimits(_window, newSize.x(), newSize.y(), _maxWindowSize.x(), _maxWindowSize.y()); + _minWindowSize = newSize; } void GlfwApplication::setMaxWindowSize(const Vector2i& size) { CORRADE_ASSERT(_window, "Platform::GlfwApplication::setMaxWindowSize(): no window opened", ); - glfwSetWindowSizeLimits(_window, _minWindowSize.x(), _minWindowSize.y(), size.x(), size.y()); - _maxWindowSize = size; + const Vector2i newSize = _dpiScaling*size; + glfwSetWindowSizeLimits(_window, _minWindowSize.x(), _minWindowSize.y(), newSize.x(), newSize.y()); + _maxWindowSize = newSize; } #endif diff --git a/src/Magnum/Platform/GlfwApplication.h b/src/Magnum/Platform/GlfwApplication.h index fcef716a1..a0dc61eba 100644 --- a/src/Magnum/Platform/GlfwApplication.h +++ b/src/Magnum/Platform/GlfwApplication.h @@ -360,8 +360,9 @@ class GlfwApplication { * @param size The minimum size, in screen coordinates * * If a value is set to @cpp -1 @ce, it will disable/remove the - * corresponding limit. - * + * corresponding limit. To make the sizing work independently of the + * display DPI, @p size is internally multiplied with @ref dpiScaling() + * before getting applied. * @note Supported since GLFW 3.2. */ void setMinWindowSize(const Vector2i& size = {-1, -1}); @@ -371,8 +372,9 @@ class GlfwApplication { * @param size The maximum size, in screen coordinates * * If a value is set to @cpp -1 @ce, it will disable/remove the - * corresponding limit. - * + * corresponding limit. To make the sizing work independently of the + * display DPI, @p size is internally multiplied with @ref dpiScaling() + * before getting applied. * @note Supported since GLFW 3.2. */ void setMaxWindowSize(const Vector2i& size = {-1, -1}); diff --git a/src/Magnum/Platform/Sdl2Application.cpp b/src/Magnum/Platform/Sdl2Application.cpp index b4e20e994..3617ec6cf 100644 --- a/src/Magnum/Platform/Sdl2Application.cpp +++ b/src/Magnum/Platform/Sdl2Application.cpp @@ -612,12 +612,16 @@ Vector2i Sdl2Application::windowSize() const { #ifndef CORRADE_TARGET_EMSCRIPTEN void Sdl2Application::setMinWindowSize(const Vector2i& size) { CORRADE_ASSERT(_window, "Platform::Sdl2Application::setMinWindowSize(): no window opened", ); - SDL_SetWindowMinimumSize(_window, size.x(), size.y()); + + const Vector2i newSize = _dpiScaling*size; + SDL_SetWindowMinimumSize(_window, newSize.x(), newSize.y()); } void Sdl2Application::setMaxWindowSize(const Vector2i& size) { CORRADE_ASSERT(_window, "Platform::Sdl2Application::setMaxWindowSize(): no window opened", ); - SDL_SetWindowMaximumSize(_window, size.x(), size.y()); + + const Vector2i newSize = _dpiScaling*size; + SDL_SetWindowMaximumSize(_window, newSize.x(), newSize.y()); } #endif diff --git a/src/Magnum/Platform/Sdl2Application.h b/src/Magnum/Platform/Sdl2Application.h index be0a33f89..f47a9d600 100644 --- a/src/Magnum/Platform/Sdl2Application.h +++ b/src/Magnum/Platform/Sdl2Application.h @@ -634,8 +634,9 @@ class Sdl2Application { * @param size The minimum size, in screen coordinates * * Note that, unlike in @ref GlfwApplication, SDL2 doesn't have a way - * to disable/remove a size limit. - * + * to disable/remove a size limit. To make the sizing work + * independently of the display DPI, @p size is internally multiplied + * with @ref dpiScaling() before getting applied. * @note Not available in @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten". */ void setMinWindowSize(const Vector2i& size); @@ -645,8 +646,9 @@ class Sdl2Application { * @param size The maximum size, in screen coordinates * * Note that, unlike in @ref GlfwApplication, SDL2 doesn't have a way - * to disable/remove a size limit. - * + * to disable/remove a size limit. To make the sizing work + * independently of the display DPI, @p size is internally multiplied + * with @ref dpiScaling() before getting applied. * @note Not available in @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten". */ void setMaxWindowSize(const Vector2i& size);