Browse Source

Windows: Fixed a bug with DPI-aware VSTs in Steinberg hosts using the OpenGL renderer

tags/2021-05-28
ed 6 years ago
parent
commit
2af1de45d7
3 changed files with 26 additions and 11 deletions
  1. +3
    -10
      modules/juce_audio_plugin_client/utility/juce_PluginUtilities.cpp
  2. +15
    -1
      modules/juce_gui_basics/native/juce_win32_Windowing.cpp
  3. +8
    -0
      modules/juce_opengl/native/juce_OpenGL_win32.h

+ 3
- 10
modules/juce_audio_plugin_client/utility/juce_PluginUtilities.cpp View File

@@ -44,18 +44,11 @@ std::function<bool(AudioProcessor&)> PluginHostType::jucePlugInIsRunningInAudioS
bool juce_isRunningInUnity() { return PluginHostType::getPluginLoadedAs() == AudioProcessor::wrapperType_Unity; }
#endif
#if JUCE_MODULE_AVAILABLE_juce_opengl && (JucePlugin_Build_VST || JucePlugin_Build_VST3)
#if JUCE_MODULE_AVAILABLE_juce_opengl && JucePlugin_Build_VST
bool juce_shouldDoubleScaleNativeGLWindow()
{
auto wrapperType = PluginHostType::getPluginLoadedAs();
auto hostType = getHostType().type;
if (wrapperType == AudioProcessor::wrapperType_VST)
return hostType == PluginHostType::SteinbergCubase10 || hostType == PluginHostType::AbletonLive10;
else if (wrapperType == AudioProcessor::wrapperType_VST3)
return hostType == PluginHostType::SteinbergCubase10;
return false;
return PluginHostType::getPluginLoadedAs() == AudioProcessor::wrapperType_VST
&& getHostType().type == PluginHostType::AbletonLive10;
}
#endif


+ 15
- 1
modules/juce_gui_basics/native/juce_win32_Windowing.cpp View File

@@ -377,6 +377,7 @@ static void setDPIAwareness()
getThreadDPIAwarenessContext = (GetThreadDPIAwarenessContextFunc) getUser32Function ("GetThreadDpiAwarenessContext");
getAwarenessFromDPIAwarenessContext = (GetAwarenessFromDpiAwarenessContextFunc) getUser32Function ("GetAwarenessFromDpiAwarenessContext");
setThreadDPIAwarenessContext = (SetThreadDPIAwarenessContextFunc) getUser32Function ("SetThreadDpiAwarenessContext");
setProcessDPIAwareness = (SetProcessDPIAwarenessFunc) GetProcAddress (shcoreModule, "SetProcessDpiAwareness");
// Only set the DPI awareness context of the process if we are a standalone app
if (! JUCEApplicationBase::isStandaloneApp())
@@ -388,7 +389,6 @@ static void setDPIAwareness()
&& SUCCEEDED (setProcessDPIAwarenessContext (DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2)))
return;
setProcessDPIAwareness = (SetProcessDPIAwarenessFunc) GetProcAddress (shcoreModule, "SetProcessDpiAwareness");
enableNonClientDPIScaling = (EnableNonClientDPIScalingFunc) getUser32Function ("EnableNonClientDpiScaling");
if (setProcessDPIAwareness != nullptr && enableNonClientDPIScaling != nullptr
@@ -4073,6 +4073,20 @@ JUCE_API bool shouldScaleGLWindow (void* hwnd)
return isPerMonitorDPIAwareWindow ((HWND) hwnd);
}
#if JUCE_WIN_PER_MONITOR_DPI_AWARE
JUCE_API void setProcessDPIAwarenessIfNecessary (void* hwnd)
{
DPI_Awareness context;
getProcessDPIAwareness (0, &context);
if (isPerMonitorDPIAwareWindow ((HWND) hwnd) && context != DPI_Awareness::DPI_Awareness_Per_Monitor_Aware
&& setProcessDPIAwareness != nullptr)
{
setProcessDPIAwareness (DPI_Awareness::DPI_Awareness_Per_Monitor_Aware);
}
}
#endif
JUCE_IMPLEMENT_SINGLETON (HWNDComponentPeer::WindowClassHolder)
//==============================================================================


+ 8
- 0
modules/juce_opengl/native/juce_OpenGL_win32.h View File

@@ -36,6 +36,10 @@ extern bool shouldScaleGLWindow (void* hwnd);
bool juce_shouldDoubleScaleNativeGLWindow() { return false; }
#endif
#if JUCE_WIN_PER_MONITOR_DPI_AWARE
void setProcessDPIAwarenessIfNecessary (void*);
#endif
//==============================================================================
class OpenGLContext::NativeContext
#if JUCE_WIN_PER_MONITOR_DPI_AWARE
@@ -101,6 +105,10 @@ public:
bool initialiseOnRenderThread (OpenGLContext& c)
{
#if JUCE_WIN_PER_MONITOR_DPI_AWARE
setProcessDPIAwarenessIfNecessary (nativeWindow->getNativeHandle());
#endif
context = &c;
return true;
}


Loading…
Cancel
Save