mirror of https://github.com/hyprwm/Hyprland
fix: deal with floating point to clamp to prev value
This commit is contained in:
parent
367ff516ef
commit
d26128c705
|
@ -637,8 +637,11 @@ Vector2D CPointerManager::closestValid(const Vector2D& pos) {
|
||||||
for (auto& b : currentMonitorLayout.monitorBoxes) {
|
for (auto& b : currentMonitorLayout.monitorBoxes) {
|
||||||
auto p = b.closestPoint(vec);
|
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
|
// 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);
|
auto distSq = p.distanceSq(vec);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue