From 8d75a7a40055f5164c7ce324ade05370758f2913 Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 23 Sep 2021 16:39:11 +0100 Subject: [PATCH] Fix auxiliary desktop windows scaling and centring when Desktop::globalScaleFactor != 1.0 --- modules/juce_gui_basics/windows/juce_AlertWindow.h | 2 +- modules/juce_gui_basics/windows/juce_DialogWindow.h | 2 +- modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/juce_gui_basics/windows/juce_AlertWindow.h b/modules/juce_gui_basics/windows/juce_AlertWindow.h index 29fc88f94a..6b59875f3a 100644 --- a/modules/juce_gui_basics/windows/juce_AlertWindow.h +++ b/modules/juce_gui_basics/windows/juce_AlertWindow.h @@ -499,7 +499,7 @@ protected: /** @internal */ int getDesktopWindowStyleFlags() const override; /** @internal */ - float getDesktopScaleFactor() const override { return desktopScale; } + float getDesktopScaleFactor() const override { return desktopScale * Desktop::getInstance().getGlobalScaleFactor(); } private: //============================================================================== diff --git a/modules/juce_gui_basics/windows/juce_DialogWindow.h b/modules/juce_gui_basics/windows/juce_DialogWindow.h index c5aa2311a3..faf25900f1 100644 --- a/modules/juce_gui_basics/windows/juce_DialogWindow.h +++ b/modules/juce_gui_basics/windows/juce_DialogWindow.h @@ -262,7 +262,7 @@ protected: /** @internal */ bool keyPressed (const KeyPress&) override; /** @internal */ - float getDesktopScaleFactor() const override { return desktopScale; } + float getDesktopScaleFactor() const override { return desktopScale * Desktop::getInstance().getGlobalScaleFactor(); } private: std::unique_ptr createAccessibilityHandler() override; diff --git a/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp b/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp index b5bd04818d..5ad7efa7d7 100644 --- a/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp @@ -298,7 +298,9 @@ void TopLevelWindow::centreAroundComponent (Component* c, const int width, const } else { - auto targetCentre = c->localPointToGlobal (c->getLocalBounds().getCentre()) / getDesktopScaleFactor(); + const auto scale = getDesktopScaleFactor() / Desktop::getInstance().getGlobalScaleFactor(); + + auto targetCentre = c->localPointToGlobal (c->getLocalBounds().getCentre()) / scale; auto parentArea = c->getParentMonitorArea(); if (auto* parent = getParentComponent())