1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

ComponentBoundsConstrainer: Properly constrain secondary windows in plugins

This commit is contained in:
reuk 2022-03-30 14:31:33 +01:00
parent 3e0fa4489a
commit 858aab823a
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11
2 changed files with 4 additions and 2 deletions

View file

@ -104,7 +104,9 @@ void ComponentBoundsConstrainer::setBoundsForComponent (Component* component,
if (auto* parent = component->getParentComponent())
return { parent->getWidth(), parent->getHeight() };
if (auto* display = Desktop::getInstance().getDisplays().getDisplayForPoint (targetBounds.getCentre()))
const auto globalBounds = component->localAreaToGlobal (targetBounds - component->getPosition());
if (auto* display = Desktop::getInstance().getDisplays().getDisplayForPoint (globalBounds.getCentre()))
return component->getLocalArea (nullptr, display->userArea) + component->getPosition();
const auto max = std::numeric_limits<int>::max();

View file

@ -294,7 +294,7 @@ void TopLevelWindow::centreAroundComponent (Component* c, const int width, const
const auto scale = getDesktopScaleFactor() / Desktop::getInstance().getGlobalScaleFactor();
auto targetCentre = c->localPointToGlobal (c->getLocalBounds().getCentre()) / scale;
auto parentArea = c->getParentMonitorArea();
auto parentArea = getLocalArea (nullptr, c->getParentMonitorArea());
if (auto* parent = getParentComponent())
{