diff --git a/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp b/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp index e4ff98ddd1..bea1a160ae 100644 --- a/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp +++ b/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp @@ -215,13 +215,28 @@ private: return dynamic_cast (currentlyOverComp.get()); } + static Component* findDesktopComponentBelow (Point screenPos) + { + Desktop& desktop = Desktop::getInstance(); + + for (int i = desktop.getNumComponents(); --i >= 0;) + { + Component* c = desktop.getComponent(i); + + if (Component* hit = c->getComponentAt (c->getLocalPoint (nullptr, screenPos))) + return hit; + } + + return nullptr; + } + DragAndDropTarget* findTarget (Point screenPos, Point& relativePos, Component*& resultComponent) const { Component* hit = getParentComponent(); if (hit == nullptr) - hit = Desktop::getInstance().findComponentAt (screenPos); + hit = findDesktopComponentBelow (screenPos); else hit = hit->getComponentAt (hit->getLocalPoint (nullptr, screenPos)); diff --git a/modules/juce_gui_basics/native/juce_linux_Windowing.cpp b/modules/juce_gui_basics/native/juce_linux_Windowing.cpp index b9bd76bbd9..4b6451ef5f 100644 --- a/modules/juce_gui_basics/native/juce_linux_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_linux_Windowing.cpp @@ -1087,9 +1087,7 @@ public: { for (int i = windowListSize; --i >= 0;) { - LinuxComponentPeer* const peer = LinuxComponentPeer::getPeerFor (windowList[i]); - - if (peer != 0) + if (LinuxComponentPeer* const peer = LinuxComponentPeer::getPeerFor (windowList[i])) { result = (peer == this); break;