mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-22 01:34:21 +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; }
|
bool juce_isRunningInUnity() { return PluginHostType::getPluginLoadedAs() == AudioProcessor::wrapperType_Unity; }
|
||||||
#endif
|
#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()
|
bool juce_shouldDoubleScaleNativeGLWindow()
|
||||||
{
|
{
|
||||||
auto wrapperType = PluginHostType::getPluginLoadedAs();
|
return PluginHostType::getPluginLoadedAs() == AudioProcessor::wrapperType_VST
|
||||||
auto hostType = getHostType().type;
|
&& getHostType().type == PluginHostType::AbletonLive10;
|
||||||
|
|
||||||
if (wrapperType == AudioProcessor::wrapperType_VST)
|
|
||||||
return hostType == PluginHostType::SteinbergCubase10 || hostType == PluginHostType::AbletonLive10;
|
|
||||||
else if (wrapperType == AudioProcessor::wrapperType_VST3)
|
|
||||||
return hostType == PluginHostType::SteinbergCubase10;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -377,6 +377,7 @@ static void setDPIAwareness()
|
||||||
getThreadDPIAwarenessContext = (GetThreadDPIAwarenessContextFunc) getUser32Function ("GetThreadDpiAwarenessContext");
|
getThreadDPIAwarenessContext = (GetThreadDPIAwarenessContextFunc) getUser32Function ("GetThreadDpiAwarenessContext");
|
||||||
getAwarenessFromDPIAwarenessContext = (GetAwarenessFromDpiAwarenessContextFunc) getUser32Function ("GetAwarenessFromDpiAwarenessContext");
|
getAwarenessFromDPIAwarenessContext = (GetAwarenessFromDpiAwarenessContextFunc) getUser32Function ("GetAwarenessFromDpiAwarenessContext");
|
||||||
setThreadDPIAwarenessContext = (SetThreadDPIAwarenessContextFunc) getUser32Function ("SetThreadDpiAwarenessContext");
|
setThreadDPIAwarenessContext = (SetThreadDPIAwarenessContextFunc) getUser32Function ("SetThreadDpiAwarenessContext");
|
||||||
|
setProcessDPIAwareness = (SetProcessDPIAwarenessFunc) GetProcAddress (shcoreModule, "SetProcessDpiAwareness");
|
||||||
|
|
||||||
// Only set the DPI awareness context of the process if we are a standalone app
|
// Only set the DPI awareness context of the process if we are a standalone app
|
||||||
if (! JUCEApplicationBase::isStandaloneApp())
|
if (! JUCEApplicationBase::isStandaloneApp())
|
||||||
|
|
@ -388,7 +389,6 @@ static void setDPIAwareness()
|
||||||
&& SUCCEEDED (setProcessDPIAwarenessContext (DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2)))
|
&& SUCCEEDED (setProcessDPIAwarenessContext (DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
setProcessDPIAwareness = (SetProcessDPIAwarenessFunc) GetProcAddress (shcoreModule, "SetProcessDpiAwareness");
|
|
||||||
enableNonClientDPIScaling = (EnableNonClientDPIScalingFunc) getUser32Function ("EnableNonClientDpiScaling");
|
enableNonClientDPIScaling = (EnableNonClientDPIScalingFunc) getUser32Function ("EnableNonClientDpiScaling");
|
||||||
|
|
||||||
if (setProcessDPIAwareness != nullptr && enableNonClientDPIScaling != nullptr
|
if (setProcessDPIAwareness != nullptr && enableNonClientDPIScaling != nullptr
|
||||||
|
|
@ -4073,6 +4073,20 @@ JUCE_API bool shouldScaleGLWindow (void* hwnd)
|
||||||
return isPerMonitorDPIAwareWindow ((HWND) 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)
|
JUCE_IMPLEMENT_SINGLETON (HWNDComponentPeer::WindowClassHolder)
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,10 @@ extern bool shouldScaleGLWindow (void* hwnd);
|
||||||
bool juce_shouldDoubleScaleNativeGLWindow() { return false; }
|
bool juce_shouldDoubleScaleNativeGLWindow() { return false; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if JUCE_WIN_PER_MONITOR_DPI_AWARE
|
||||||
|
void setProcessDPIAwarenessIfNecessary (void*);
|
||||||
|
#endif
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
class OpenGLContext::NativeContext
|
class OpenGLContext::NativeContext
|
||||||
#if JUCE_WIN_PER_MONITOR_DPI_AWARE
|
#if JUCE_WIN_PER_MONITOR_DPI_AWARE
|
||||||
|
|
@ -101,6 +105,10 @@ public:
|
||||||
|
|
||||||
bool initialiseOnRenderThread (OpenGLContext& c)
|
bool initialiseOnRenderThread (OpenGLContext& c)
|
||||||
{
|
{
|
||||||
|
#if JUCE_WIN_PER_MONITOR_DPI_AWARE
|
||||||
|
setProcessDPIAwarenessIfNecessary (nativeWindow->getNativeHandle());
|
||||||
|
#endif
|
||||||
|
|
||||||
context = &c;
|
context = &c;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue