Looks like when JUCE_WIN_PER_MONITOR_DPI_AWARE is disabled ,
Desktop::getInstance().getGlobalScaleFactor() returns the system set scale which in my case is 1.25 (125%).
However AlertWindow and DefaultDialogWindow desktopScale member get set to 1.0f.
Those patches seem to resolve the issue.
juce_AlertWindow.cpp (Line : 39)
AlertWindow::AlertWindow (const String& title,
const String& message,
MessageBoxIconType iconType,
Component* comp)
: TopLevelWindow (title, true),
alertIconType (iconType),
associatedComponent (comp),
#if JUCE_WIN_PER_MONITOR_DPI_AWARE
desktopScale (comp != nullptr ? Component::getApproximateScaleFactorForComponent (comp) : 1.0f)
#else
desktopScale (Desktop::getInstance().getGlobalScaleFactor())
#endif
{
setAlwaysOnTop (juce_areThereAnyAlwaysOnTopWindows());
accessibleMessageLabel.setColour (Label::textColourId, Colours::transparentBlack);
addAndMakeVisible (accessibleMessageLabel);
if (message.isEmpty())
text = " "; // to force an update if the message is empty
setMessage (message);
AlertWindow::lookAndFeelChanged();
constrainer.setMinimumOnscreenAmounts (0x10000, 0x10000, 0x10000, 0x10000);
}
juce_DialogWindow.cpp (Line : 79)
DefaultDialogWindow (LaunchOptions& options)
: DialogWindow (options.dialogTitle, options.dialogBackgroundColour,
options.escapeKeyTriggersCloseButton, true,
#if JUCE_WIN_PER_MONITOR_DPI_AWARE
options.componentToCentreAround != nullptr
? Component::getApproximateScaleFactorForComponent (options.componentToCentreAround)
: 1.0f)
#else
Desktop::getInstance().getGlobalScaleFactor())
#endif
{
setUsingNativeTitleBar (options.useNativeTitleBar);
setAlwaysOnTop (juce_areThereAnyAlwaysOnTopWindows());
if (options.content.willDeleteObject())
setContentOwned (options.content.release(), true);
else
setContentNonOwned (options.content.release(), true);
centreAroundComponent (options.componentToCentreAround, getWidth(), getHeight());
setResizable (options.resizable, options.useBottomRightCornerResizer);
}
juce_TopLevelWindow.cpp (Line : 290)
void TopLevelWindow::centreAroundComponent (Component* c, const int width, const int height)
{
if (c == nullptr)
c = TopLevelWindow::getActiveTopLevelWindow();
if (c == nullptr || c->getBounds().isEmpty())
{
centreWithSize (width, height);
}
else
{
#if JUCE_WIN_PER_MONITOR_DPI_AWARE
auto targetCentre = c->localPointToGlobal (c->getLocalBounds().getCentre()) / getDesktopScaleFactor();
#else
auto targetCentre = c->localPointToGlobal (c->getLocalBounds().getCentre());
#endif
auto parentArea = c->getParentMonitorArea();
if (auto* parent = getParentComponent())
{
targetCentre = parent->getLocalPoint (nullptr, targetCentre);
parentArea = parent->getLocalBounds();
}
setBounds (Rectangle<int> (targetCentre.x - width / 2,
targetCentre.y - height / 2,
width, height)
.constrainedWithin (parentArea.reduced (12, 12)));
}
}