mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Windows: Add helper to find client rect in screen coordinates
This commit is contained in:
parent
d344c2bf71
commit
4a76872f54
1 changed files with 15 additions and 18 deletions
|
|
@ -1680,13 +1680,7 @@ public:
|
||||||
return snapped;
|
return snapped;
|
||||||
}
|
}
|
||||||
|
|
||||||
RECT rect{};
|
const auto logicalClient = convertPhysicalScreenRectangleToLogical (getClientRectInScreen(), hwnd);
|
||||||
GetClientRect (hwnd, &rect);
|
|
||||||
auto points = readUnaligned<std::array<POINT, 2>> (&rect);
|
|
||||||
MapWindowPoints (hwnd, nullptr, points.data(), (UINT) points.size());
|
|
||||||
|
|
||||||
const auto mappedRect = readUnaligned<RECT> (points.data());
|
|
||||||
const auto logicalClient = convertPhysicalScreenRectangleToLogical (D2DUtilities::toRectangle (mappedRect), hwnd);
|
|
||||||
return logicalClient;
|
return logicalClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1798,6 +1792,19 @@ public:
|
||||||
return wp.showCmd == SW_SHOWMAXIMIZED;
|
return wp.showCmd == SW_SHOWMAXIMIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rectangle<int> getClientRectInScreen() const
|
||||||
|
{
|
||||||
|
ScopedThreadDPIAwarenessSetter setter { hwnd };
|
||||||
|
|
||||||
|
RECT rect{};
|
||||||
|
GetClientRect (hwnd, &rect);
|
||||||
|
auto points = readUnaligned<std::array<POINT, 2>> (&rect);
|
||||||
|
MapWindowPoints (hwnd, nullptr, points.data(), (UINT) points.size());
|
||||||
|
const auto result = readUnaligned<RECT> (&points);
|
||||||
|
|
||||||
|
return D2DUtilities::toRectangle (result);
|
||||||
|
}
|
||||||
|
|
||||||
bool contains (Point<int> localPos, bool trueIfInAChildWindow) const override
|
bool contains (Point<int> localPos, bool trueIfInAChildWindow) const override
|
||||||
{
|
{
|
||||||
auto r = convertPhysicalScreenRectangleToLogical (D2DUtilities::toRectangle (getWindowScreenRect (hwnd)), hwnd);
|
auto r = convertPhysicalScreenRectangleToLogical (D2DUtilities::toRectangle (getWindowScreenRect (hwnd)), hwnd);
|
||||||
|
|
@ -1808,17 +1815,7 @@ public:
|
||||||
const auto screenPos = convertLogicalScreenPointToPhysical (localPos + getScreenPosition(), hwnd);
|
const auto screenPos = convertLogicalScreenPointToPhysical (localPos + getScreenPosition(), hwnd);
|
||||||
|
|
||||||
if (trueIfInAChildWindow)
|
if (trueIfInAChildWindow)
|
||||||
{
|
return getClientRectInScreen().contains (screenPos);
|
||||||
// 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));
|
auto w = WindowFromPoint (D2DUtilities::toPOINT (screenPos));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue