Browse Source

Tweak to DragAndDropContainer to avoid problems detecting the window that's being dragged over.

tags/2021-05-28
jules 11 years ago
parent
commit
31b912bc87
2 changed files with 17 additions and 4 deletions
  1. +16
    -1
      modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp
  2. +1
    -3
      modules/juce_gui_basics/native/juce_linux_Windowing.cpp

+ 16
- 1
modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp View File

@@ -215,13 +215,28 @@ private:
return dynamic_cast<DragAndDropTarget*> (currentlyOverComp.get());
}
static Component* findDesktopComponentBelow (Point<int> 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<int> screenPos, Point<int>& 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));


+ 1
- 3
modules/juce_gui_basics/native/juce_linux_Windowing.cpp View File

@@ -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;


Loading…
Cancel
Save