1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-20 01:14:20 +00:00

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.
This commit is contained in:
reuk 2022-03-29 21:42:48 +01:00
parent 858aab823a
commit 4bfcb78809
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11
2 changed files with 22 additions and 0 deletions

View file

@ -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<ScopedThreadDPIAwarenessSetter>
{
if (auto* target = options.getTargetComponent())
if (auto* handle = target->getWindowHandle())
return std::make_unique<ScopedThreadDPIAwarenessSetter> (handle);
return nullptr;
}();
#endif
return items.isEmpty() ? nullptr
: new HelperClasses::MenuWindow (*this, nullptr, options,
! options.getTargetScreenArea().isEmpty(),

View file

@ -31,6 +31,17 @@ public:
if (comp->isOnDesktop())
{
#if JUCE_WINDOWS
const auto scope = [&]() -> std::unique_ptr<ScopedThreadDPIAwarenessSetter>
{
if (comp != nullptr)
if (auto* handle = comp->getWindowHandle())
return std::make_unique<ScopedThreadDPIAwarenessSetter> (handle);
return nullptr;
}();
#endif
setSize (1, 1); // to keep the OS happy by not having zero-size windows
addToDesktop (ComponentPeer::windowIgnoresMouseClicks
| ComponentPeer::windowIsTemporary