1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-20 01:14:20 +00:00

LinuxComponentPeer: Properly transform coordinates into peer space when collision testing

This commit is contained in:
reuk 2022-03-15 14:48:09 +00:00
parent 092314deac
commit 3e0fa4489a
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11

View file

@ -147,12 +147,12 @@ public:
Point<float> localToGlobal (Point<float> relativePosition) override
{
return relativePosition + getScreenPosition (false).toFloat();
return localToGlobal (*this, relativePosition);
}
Point<float> globalToLocal (Point<float> screenPosition) override
{
return screenPosition - getScreenPosition (false).toFloat();
return globalToLocal (*this, screenPosition);
}
using ComponentPeer::localToGlobal;
@ -231,8 +231,11 @@ public:
if (! c->isVisible())
continue;
if (auto* peer = c->getPeer())
if (peer->contains (localPos + bounds.getPosition() - peer->getBounds().getPosition(), true))
auto* otherPeer = c->getPeer();
jassert (otherPeer == nullptr || dynamic_cast<LinuxComponentPeer*> (c->getPeer()) != nullptr);
if (auto* peer = static_cast<LinuxComponentPeer*> (otherPeer))
if (peer->contains (globalToLocal (*peer, localToGlobal (*this, localPos.toFloat())).roundToInt(), true))
return false;
}
@ -474,6 +477,19 @@ private:
JUCE_DECLARE_NON_COPYABLE (LinuxRepaintManager)
};
//==============================================================================
template <typename This>
static Point<float> localToGlobal (This& t, Point<float> relativePosition)
{
return relativePosition + t.getScreenPosition (false).toFloat();
}
template <typename This>
static Point<float> globalToLocal (This& t, Point<float> screenPosition)
{
return screenPosition - t.getScreenPosition (false).toFloat();
}
//==============================================================================
void settingChanged (const XWindowSystemUtilities::XSetting& settingThatHasChanged) override
{