From 64cd94f8ae32d7c9da3125ce1fe62c2267ded331 Mon Sep 17 00:00:00 2001 From: ed Date: Wed, 2 Jan 2019 14:40:45 +0000 Subject: [PATCH] VST3: Added a workaround for Windows DPI-aware Cubase 10 opening plug-in editor with double scaled bounds --- .../VST3/juce_VST3_Wrapper.cpp | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp index a0e7ff28e4..020e126364 100644 --- a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp @@ -908,6 +908,23 @@ private: #if JUCE_WINDOWS && JUCE_WIN_PER_MONITOR_DPI_AWARE w = roundToInt (w / editorScaleFactor); h = roundToInt (h / editorScaleFactor); + + bool needToResizeHostWindow = false; + + if (getHostType().type == PluginHostType::SteinbergCubase10) + { + auto integerScaleFactor = (int) std::round (editorScaleFactor); + + // Workaround for Cubase 10 sending double-scaled bounds when opening editor + if (isWithin ((int) w, component->getWidth() * integerScaleFactor, 2) + && isWithin ((int) h, component->getHeight() * integerScaleFactor, 2)) + { + w /= integerScaleFactor; + h /= integerScaleFactor; + + needToResizeHostWindow = true; + } + } #endif component->setSize (w, h); @@ -919,6 +936,11 @@ private: #endif if (auto* peer = component->getPeer()) peer->updateBounds(); + + #if JUCE_WINDOWS && JUCE_WIN_PER_MONITOR_DPI_AWARE + if (needToResizeHostWindow) + component->resizeHostWindow(); + #endif } return kResultTrue;