Browse Source

LinuxComponentPeer: Properly transform coordinates into peer space when collision testing

pull/22/head
reuk 3 years ago
parent
commit
3e0fa4489a
No known key found for this signature in database GPG Key ID: 9ADCD339CFC98A11
1 changed files with 20 additions and 4 deletions
  1. +20
    -4
      modules/juce_gui_basics/native/juce_linux_Windowing.cpp

+ 20
- 4
modules/juce_gui_basics/native/juce_linux_Windowing.cpp 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
{


Loading…
Cancel
Save