1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Windowing: Reinstate old WindowFromPoint behaviour in ComponentPeer::contains

This reverts 515e9b9f89.

In order to avoid recursive calls through WM_NCHITTEST, we remove calls
to Component::contains in DocumentWindow::findControlAtPoint.
This commit is contained in:
reuk 2024-10-01 20:34:48 +01:00
parent ad5a755b10
commit fdf74a7477
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C
3 changed files with 6 additions and 5 deletions

View file

@ -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<float>) const { return WindowControlKind::client; }

View file

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

View file

@ -341,7 +341,7 @@ auto DocumentWindow::findControlAtPoint (Point<float> 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;