From a8e592d8a849246508e4c9301cdeb89b13271ffb Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 29 Nov 2019 15:15:26 +0000 Subject: [PATCH] VST3: Scale the ContextMenu coords correctly in DPI-aware hosts --- .../format_types/juce_VST3PluginFormat.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp index d3d4bbe3a7..2f2a33750c 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp @@ -3026,7 +3026,19 @@ tresult VST3HostContext::ContextMenu::popup (Steinberg::UCoord x, Steinberg::UCo PopupMenu::Options options; if (auto* ed = owner.getActiveEditor()) + { + #if JUCE_WINDOWS && JUCE_WIN_PER_MONITOR_DPI_AWARE + if (auto* peer = ed->getPeer()) + { + auto scale = peer->getPlatformScaleFactor(); + + x = roundToInt (x / scale); + y = roundToInt (y / scale); + } + #endif + options = options.withTargetScreenArea (ed->getScreenBounds().translated ((int) x, (int) y).withSize (1, 1)); + } #if JUCE_MODAL_LOOPS_PERMITTED // Unfortunately, Steinberg's docs explicitly say this should be modal..