Browse Source

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.
pull/22/head
reuk 3 years ago
parent
commit
4bfcb78809
No known key found for this signature in database GPG Key ID: 9ADCD339CFC98A11
2 changed files with 22 additions and 0 deletions
  1. +11
    -0
      modules/juce_gui_basics/menus/juce_PopupMenu.cpp
  2. +11
    -0
      modules/juce_gui_basics/misc/juce_DropShadower.cpp

+ 11
- 0
modules/juce_gui_basics/menus/juce_PopupMenu.cpp 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(),


+ 11
- 0
modules/juce_gui_basics/misc/juce_DropShadower.cpp 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


Loading…
Cancel
Save