mirror of https://github.com/hyprwm/Hyprland
fix: adjusting clamp after getting closest point to fix getting off limit point
This commit is contained in:
parent
fbfb470bde
commit
b81aa11c8b
|
@ -635,7 +635,11 @@ Vector2D CPointerManager::closestValid(const Vector2D& pos) {
|
||||||
float distanceSq = __FLT_MAX__;
|
float distanceSq = __FLT_MAX__;
|
||||||
|
|
||||||
for (auto& b : currentMonitorLayout.monitorBoxes) {
|
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);
|
auto distSq = p.distanceSq(vec);
|
||||||
|
|
||||||
if (distSq < distanceSq) {
|
if (distSq < distanceSq) {
|
||||||
|
|
Loading…
Reference in New Issue