Skip to content

Commit

Permalink
Windowing: Avoid recursively calling WM_NCHITTEST in contains()
Browse files Browse the repository at this point in the history
  • Loading branch information
reuk committed Jun 26, 2024
1 parent adbb085 commit 515e9b9
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions modules/juce_gui_basics/native/juce_Windowing_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1782,8 +1782,22 @@ class HWNDComponentPeer final : public ComponentPeer
if (! r.withZeroOrigin().contains (localPos))
return false;

auto w = WindowFromPoint (D2DUtilities::toPOINT (convertLogicalScreenPointToPhysical (localPos + getScreenPosition(),
hwnd)));
const auto screenPos = convertLogicalScreenPointToPhysical (localPos + getScreenPosition(), hwnd);

if (trueIfInAChildWindow)
{
// Quick check to see whether the point is inside the client bounds
RECT rect;
GetClientRect (hwnd, &rect);
POINT points[2];
memcpy (points, &rect, sizeof (points));
MapWindowPoints (hwnd, nullptr, points, (UINT) std::size (points));
memcpy (&rect, points, sizeof (points));

return PtInRect (&rect, D2DUtilities::toPOINT (screenPos));
}

auto w = WindowFromPoint (D2DUtilities::toPOINT (screenPos));

return w == hwnd || (trueIfInAChildWindow && (IsChild (hwnd, w) != 0));
}
Expand Down

0 comments on commit 515e9b9

Please sign in to comment.