Browse Source

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

tags/2021-05-28
ed 8 years ago
parent
commit
37c243bb49
1 changed files with 28 additions and 4 deletions
  1. +28
    -4
      modules/juce_audio_plugin_client/utility/juce_FakeMouseMoveGenerator.h

+ 28
- 4
modules/juce_audio_plugin_client/utility/juce_FakeMouseMoveGenerator.h 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


Loading…
Cancel
Save