From 8f99c084feab058a0693df3df3d3d03b354a2d03 Mon Sep 17 00:00:00 2001 From: attila Date: Tue, 17 May 2022 15:42:39 +0200 Subject: [PATCH] Linux: Adjust natively reported border size by the current scale factor --- modules/juce_graphics/geometry/juce_BorderSize.h | 10 ++++++++++ .../juce_gui_basics/native/juce_linux_Windowing.cpp | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/juce_graphics/geometry/juce_BorderSize.h b/modules/juce_graphics/geometry/juce_BorderSize.h index 7510cb35cd..681fc4e86a 100644 --- a/modules/juce_graphics/geometry/juce_BorderSize.h +++ b/modules/juce_graphics/geometry/juce_BorderSize.h @@ -145,6 +145,16 @@ public: other.right + right }; } + /** Multiplies each member of the border by a scalar. */ + template + BorderSize multipliedBy (ScalarType scalar) const noexcept + { + return { static_cast (scalar * top), + static_cast (scalar * left), + static_cast (scalar * bottom), + static_cast (scalar * right) }; + } + //============================================================================== bool operator== (const BorderSize& other) const noexcept { return tie() == other.tie(); } bool operator!= (const BorderSize& other) const noexcept { return tie() != other.tie(); } diff --git a/modules/juce_gui_basics/native/juce_linux_Windowing.cpp b/modules/juce_gui_basics/native/juce_linux_Windowing.cpp index 7f4c185d48..0f49dce757 100644 --- a/modules/juce_gui_basics/native/juce_linux_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_linux_Windowing.cpp @@ -377,7 +377,13 @@ public: else if (! windowBorder || ((*windowBorder).getTopAndBottom() == 0 && (*windowBorder).getLeftAndRight() == 0)) { - windowBorder = XWindowSystem::getInstance()->getBorderSize (windowH); + windowBorder = [&]() + { + if (auto unscaledBorderSize = XWindowSystem::getInstance()->getBorderSize (windowH)) + return OptionalBorderSize { (*unscaledBorderSize).multipliedBy (1.0 / currentScaleFactor) }; + + return OptionalBorderSize {}; + }(); } }