From 6f3fb5a29f20e4cb54faf4d1a0d64b4bd6b6a88f 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 fd8241b338..bbf7593d39 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 e828e69c41..7eb7176e17 100644 --- a/modules/juce_gui_basics/native/juce_linux_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_linux_Windowing.cpp @@ -380,7 +380,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 {}; + }(); } }