mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Windows: Fixed a bug with DPI-aware VSTs in Steinberg hosts using the OpenGL renderer
This commit is contained in:
parent
2830ecec0a
commit
2af1de45d7
3 changed files with 26 additions and 11 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -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…
Add table
Add a link
Reference in a new issue