fix: deal with floating point to clamp to prev value

This commit is contained in:
drendog 2024-06-25 21:17:22 +02:00
parent 367ff516ef
commit d26128c705
1 changed files with 4 additions and 1 deletions

View File

@ -637,8 +637,11 @@ Vector2D CPointerManager::closestValid(const Vector2D& pos) {
for (auto& b : currentMonitorLayout.monitorBoxes) {
auto p = b.closestPoint(vec);
auto max_x = std::nextafter(b.x + b.w, b.x + b.w - 1);
auto max_y = std::nextafter(b.y + b.h, b.y + b.h - 1);
// 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)};
p = Vector2D{std::clamp(p.x, b.x, max_x), std::clamp(p.y, b.y, max_y)};
auto distSq = p.distanceSq(vec);