I’m testing my plugin in the non-DPI-aware Steinberg VST validator tool on a Windows machine with multiple displays connected. My plugin calls juce::Desktop::getInstance()
which always triggers the following assert in void Displays::updateToLogical()
:
// All of the nodes should have a parent
jassert (node.parent != nullptr);
I think I’ve tracked down the problem to my particular arrangement of displays. My primary display is a low DPI monitor with the text scaling set to 100%, and to its left is the high DPI laptop monitor with the text scaling set to 250%.
The following code in processDisplay (DisplayNode* currentNode, Array<DisplayNode>& allNodes)
is supposed to find the parent for the secondary display:
// If the displays are touching on any side
if (otherPhysicalArea.getX() == physicalArea.getRight() || otherPhysicalArea.getRight() == physicalArea.getX()
|| otherPhysicalArea.getY() == physicalArea.getBottom() || otherPhysicalArea.getBottom() == physicalArea.getY())
{
node.parent = currentNode;
children.add (&node);
}
As this is a plugin rather than a standalone application, the setDPIAwareness
call in juce_win32_Windowing.cpp never sets up any of the DPI-aware functions and the scale for the high-DPI monitor is defaulted to the system DPI in enumMonitorsProc
.
At the time of the call to juce::Desktop::getInstance()
the displays are in the following state:
Display [0] // primary, low DPI
isMain true
totalArea {pos={x=0 y=0 } w=1920 h=1200 }
userArea {pos={x=0 y=0 } w=1920 h=1160 }
topLeftPhysical {x=0 y=0 }
scale 1.0000000000000000
dpi 96.000000000000000
isRoot true
Display [1] // secondary, to the left of the primary, high DPI
isMain false
totalArea {pos={x=-3840 y=0 } w=1536 h=864 }
userArea {pos={x=-3840 y=0 } w=1536 h=864 }
topLeftPhysical {x=0 y=0 }
scale 1.0000000000000000
dpi 96.000000000000000
isRoot false
The position of display 1 is based on actual pixels but the width & height reflect the 250% scaling factor set up for that display. In JUCE, the right edge of display 1 is deemed not to be touching the left edge of display 0, no parent is thus set and the assert fires.
The assert is more of an distraction when debugging than anything else, but I do wonder if the parent not being set up correctly might also have other implications I’m not aware of?