From 4bfcb7880985c3660f61e30e67ffe3c8d48acd3a Mon Sep 17 00:00:00 2001 From: reuk Date: Tue, 29 Mar 2022 21:42:48 +0100 Subject: [PATCH] PopupMenu: Use DPI awareness of target component when creating new windows Also updates the drop shadower so that the DPI-awareness of the shadows matches the DPI-awareness of the shadowed component. --- modules/juce_gui_basics/menus/juce_PopupMenu.cpp | 11 +++++++++++ modules/juce_gui_basics/misc/juce_DropShadower.cpp | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp index e2c8738799..2a357bd4fb 100644 --- a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp +++ b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp @@ -2017,6 +2017,17 @@ PopupMenu::Options PopupMenu::Options::withInitiallySelectedItem (int idOfItemTo Component* PopupMenu::createWindow (const Options& options, ApplicationCommandManager** managerOfChosenCommand) const { + #if JUCE_WINDOWS + const auto scope = [&]() -> std::unique_ptr + { + if (auto* target = options.getTargetComponent()) + if (auto* handle = target->getWindowHandle()) + return std::make_unique (handle); + + return nullptr; + }(); + #endif + return items.isEmpty() ? nullptr : new HelperClasses::MenuWindow (*this, nullptr, options, ! options.getTargetScreenArea().isEmpty(), diff --git a/modules/juce_gui_basics/misc/juce_DropShadower.cpp b/modules/juce_gui_basics/misc/juce_DropShadower.cpp index 45301ad3de..fe21871861 100644 --- a/modules/juce_gui_basics/misc/juce_DropShadower.cpp +++ b/modules/juce_gui_basics/misc/juce_DropShadower.cpp @@ -31,6 +31,17 @@ public: if (comp->isOnDesktop()) { + #if JUCE_WINDOWS + const auto scope = [&]() -> std::unique_ptr + { + if (comp != nullptr) + if (auto* handle = comp->getWindowHandle()) + return std::make_unique (handle); + + return nullptr; + }(); + #endif + setSize (1, 1); // to keep the OS happy by not having zero-size windows addToDesktop (ComponentPeer::windowIgnoresMouseClicks | ComponentPeer::windowIsTemporary