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

Fixed a bug in plug-ins on Mac where mouse exit events weren't being sent when the mouse cursor left the plug-in window

This commit is contained in:
ed 2017-08-31 12:04:07 +01:00
parent a7b9da40a2
commit 37c243bb49

View file

@ -41,24 +41,48 @@ public:
void timerCallback() override
{
// Workaround for windows not getting mouse-moves...
const Point<float> screenPos (Desktop::getInstance().getMainMouseSource().getScreenPosition());
auto screenPos = Desktop::getInstance().getMainMouseSource().getScreenPosition();
if (screenPos != lastScreenPos)
{
lastScreenPos = screenPos;
const ModifierKeys mods (ModifierKeys::getCurrentModifiers());
auto mods = ModifierKeys::getCurrentModifiers();
if (! mods.isAnyMouseButtonDown())
if (Component* const comp = Desktop::getInstance().findComponentAt (screenPos.roundToInt()))
if (ComponentPeer* const peer = comp->getPeer())
{
if (auto* comp = Desktop::getInstance().findComponentAt (screenPos.roundToInt()))
{
safeOldComponent = comp;
if (auto* peer = comp->getPeer())
{
if (! peer->isFocused())
{
peer->handleMouseEvent (MouseInputSource::InputSourceType::mouse, peer->globalToLocal (screenPos), mods,
MouseInputSource::invalidPressure, MouseInputSource::invalidOrientation, Time::currentTimeMillis());
}
}
}
else
{
if (safeOldComponent != nullptr)
{
if (auto* peer = safeOldComponent->getPeer())
{
peer->handleMouseEvent (MouseInputSource::InputSourceType::mouse, { -1.0f, -1.0f }, mods,
MouseInputSource::invalidPressure, MouseInputSource::invalidOrientation, Time::currentTimeMillis());
}
}
safeOldComponent = nullptr;
}
}
}
}
private:
Point<float> lastScreenPos;
WeakReference<Component> safeOldComponent;
};
#else