Is it possible to get the current scale factor from a plugin running in Windows? I am using the following code to get the scale:
const auto scale = juce::Desktop::getInstance().getDisplays().getDisplayForRect(comp.getTopLevelComponent()->getScreenBounds())->scale;
This works fine for a standalone build but when running as a plugin in FL Studio I always get 1.0.
I need this as I’m hosting plugins and showing their editor within my plugin window, and when I get the hosted plugin’s editor component the reported bounds are incorrect and need to have the Windows DPI scaling applied.
EDIT: The issue essentially seems to be that the bounds reported by AudioProcessor::activeEditor are incorrect, and do not take into account the Windows system scaling settings.
This does not seem to be an issue when the AudioProcessorEditor is in it’s own OS window.
Alright, I’ve found a clue to a possible solution:
Currently, Desktop::getDefaultMasterScale() will return 1.0 if called from a plugin or a “per monitor aware process”.
double Desktop::getDefaultMasterScale()
{
if (! JUCEApplicationBase::isStandaloneApp() || isPerMonitorDPIAwareProcess())
return 1.0;
return getGlobalDPI() / USER_DEFAULT_SCREEN_DPI; // <-- this is the value I need
}
That seems to make sense because commenting those lines mashes up all sorts of things regarding plugin window sizes.
However, I think that “defaultMasterScale” value is still needed to report the size of a hosted plugin’s editor. Or I just need to get at the value of getGlobalDPI() / USER_DEFAULT_SCREEN_DPI so I can determine the actual size of the plugin’s editor.