fix: adjusting clamp after getting closest point to fix getting off limit point

This commit is contained in:
drendog 2024-06-24 14:09:59 +02:00
parent fbfb470bde
commit b81aa11c8b
1 changed files with 5 additions and 1 deletions

View File

@ -635,7 +635,11 @@ Vector2D CPointerManager::closestValid(const Vector2D& pos) {
float distanceSq = __FLT_MAX__;
for (auto& b : currentMonitorLayout.monitorBoxes) {
auto p = b.closestPoint(vec);
auto p = b.closestPoint(vec);
// because closestPoint does clamp up to x + w and y + h
p = Vector2D{std::clamp(p.x, b.x, b.x + b.w - 1), std::clamp(p.y, b.y, b.y + b.h - 1)};
auto distSq = p.distanceSq(vec);
if (distSq < distanceSq) {