diff --git a/modules/juce_gui_basics/components/juce_Component.h b/modules/juce_gui_basics/components/juce_Component.h index 443a81dcaa..14a103a1be 100644 --- a/modules/juce_gui_basics/components/juce_Component.h +++ b/modules/juce_gui_basics/components/juce_Component.h @@ -926,6 +926,11 @@ public: stretch a window vertically, and the window tiling flyout that appears when hovering the mouse over the maximise button. + It's dangerous to call Component::contains from an overriding function, because this might + call into the peer to do system hit-testing - but the system hit-test could in turn call + findControlAtPoint, leading to infinite recursion. It's better to use functions like + Rectangle::contains or Path::contains to test for the window control areas. + This is called by the peer. Component subclasses may override this but should not call it directly. */ virtual WindowControlKind findControlAtPoint (Point) const { return WindowControlKind::client; } diff --git a/modules/juce_gui_basics/native/juce_Windowing_windows.cpp b/modules/juce_gui_basics/native/juce_Windowing_windows.cpp index d099e09413..1b512343f6 100644 --- a/modules/juce_gui_basics/native/juce_Windowing_windows.cpp +++ b/modules/juce_gui_basics/native/juce_Windowing_windows.cpp @@ -1793,11 +1793,7 @@ public: const auto screenPos = convertLogicalScreenPointToPhysical (localPos + getScreenPosition(), hwnd); - if (trueIfInAChildWindow) - return getClientRectInScreen().contains (screenPos); - auto w = WindowFromPoint (D2DUtilities::toPOINT (screenPos)); - return w == hwnd || (trueIfInAChildWindow && (IsChild (hwnd, w) != 0)); } diff --git a/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp b/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp index ec330c1b14..a40df3aa55 100644 --- a/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp @@ -341,7 +341,7 @@ auto DocumentWindow::findControlAtPoint (Point pt) const -> WindowControl } for (const auto& c : getChildren()) - if (c->contains (c->getLocalPoint (this, pt))) + if (detail::ComponentHelpers::hitTest (*c, c->getLocalPoint (this, pt))) return WindowControlKind::client; return WindowControlKind::caption;