From 630afbda549d8b4ec7c2beefa8b73b9a5765e641 Mon Sep 17 00:00:00 2001 From: reuk Date: Thu, 1 Jul 2021 12:23:59 +0100 Subject: [PATCH] NSViewComponentPeer: Avoid processing mouse events from tracking areas Some plugins (Izotope Relay, some older DPF plugins) use NSTrackingAreas to handle mouse events, but unprocessed events seemingly get passed up to outer views. Processing these events was causing unexpected behaviour. For example, if the cursor entered a plugin view while dragging a JUCE window border, a mouseEnter event was be generated, interrupting the drag. We now check whether mouse events were generated by an NSTrackingArea which does not belong to the JUCE view, and ignore the event in this case. --- .../native/juce_mac_NSViewComponentPeer.mm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index b933f2a954..e1c3473c98 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -636,6 +636,9 @@ public: void redirectMouseEnter (NSEvent* ev) { + if (shouldIgnoreMouseEnterExit (ev)) + return; + Desktop::getInstance().getMainMouseSource().forceMouseCursorUpdate(); ModifierKeys::currentModifiers = ModifierKeys::currentModifiers.withoutMouseButtons(); sendMouseEvent (ev); @@ -643,6 +646,9 @@ public: void redirectMouseExit (NSEvent* ev) { + if (shouldIgnoreMouseEnterExit (ev)) + return; + ModifierKeys::currentModifiers = ModifierKeys::currentModifiers.withoutMouseButtons(); sendMouseEvent (ev); } @@ -1513,6 +1519,12 @@ private: static NSView* createViewInstance(); static NSWindow* createWindowInstance(); + bool shouldIgnoreMouseEnterExit (NSEvent* ev) const + { + auto* eventTrackingArea = [ev trackingArea]; + return eventTrackingArea != nil && ! [[view trackingAreas] containsObject: eventTrackingArea]; + } + static void setOwner (id viewOrWindow, NSViewComponentPeer* newOwner) { object_setInstanceVariable (viewOrWindow, "owner", newOwner);