From dc470480a6c314ecfe62d887adf91cab540b875d Mon Sep 17 00:00:00 2001 From: drendog <53359960+drendog@users.noreply.github.com> Date: Sat, 11 May 2024 23:49:23 +0200 Subject: [PATCH 1/6] fix: change min cursor padding to 0 --- src/managers/PointerManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp index 663456f8bc9..e98059f347e 100644 --- a/src/managers/PointerManager.cpp +++ b/src/managers/PointerManager.cpp @@ -544,7 +544,7 @@ CBox CPointerManager::getCursorBoxGlobal() { Vector2D CPointerManager::closestValid(const Vector2D& pos) { static auto PADDING = CConfigValue("cursor:hotspot_padding"); - auto CURSOR_PADDING = std::clamp((int)*PADDING, 1, 100); // 1px + auto CURSOR_PADDING = std::clamp((int)*PADDING, 0, 100); CBox hotBox = {{pos.x - CURSOR_PADDING, pos.y - CURSOR_PADDING}, {2 * CURSOR_PADDING, 2 * CURSOR_PADDING}}; // From e089662ae23b5edb93182e354049cbdfd0da8d90 Mon Sep 17 00:00:00 2001 From: drendog <53359960+drendog@users.noreply.github.com> Date: Sun, 12 May 2024 00:52:33 +0200 Subject: [PATCH 2/6] chore: set default hotspot padding to 0 --- src/config/ConfigManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 4a75ca1d70f..df123e76ac7 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -510,7 +510,7 @@ CConfigManager::CConfigManager() { m_pConfig->addConfigValue("opengl:force_introspection", Hyprlang::INT{2}); m_pConfig->addConfigValue("cursor:no_hardware_cursors", Hyprlang::INT{0}); - m_pConfig->addConfigValue("cursor:hotspot_padding", Hyprlang::INT{1}); + m_pConfig->addConfigValue("cursor:hotspot_padding", Hyprlang::INT{0}); m_pConfig->addConfigValue("cursor:inactive_timeout", Hyprlang::INT{0}); m_pConfig->addConfigValue("cursor:no_warps", Hyprlang::INT{0}); m_pConfig->addConfigValue("cursor:default_monitor", {STRVAL_EMPTY}); From b81aa11c8b17cedf6a961073adb1b93cf889de8d Mon Sep 17 00:00:00 2001 From: drendog <53359960+drendog@users.noreply.github.com> Date: Mon, 24 Jun 2024 14:09:59 +0200 Subject: [PATCH 3/6] fix: adjusting clamp after getting closest point to fix getting off limit point --- src/managers/PointerManager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp index 973b7e27196..bd92b1faaca 100644 --- a/src/managers/PointerManager.cpp +++ b/src/managers/PointerManager.cpp @@ -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) { From d26128c7051e1c9ad0c8af05f94c70d54f615562 Mon Sep 17 00:00:00 2001 From: drendog <53359960+drendog@users.noreply.github.com> Date: Tue, 25 Jun 2024 21:17:22 +0200 Subject: [PATCH 4/6] fix: deal with floating point to clamp to prev value --- src/managers/PointerManager.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp index bd92b1faaca..ab9e4785999 100644 --- a/src/managers/PointerManager.cpp +++ b/src/managers/PointerManager.cpp @@ -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); From 712916a450a8aab23f929322d450455ddd9fa197 Mon Sep 17 00:00:00 2001 From: drendog <53359960+drendog@users.noreply.github.com> Date: Thu, 27 Jun 2024 21:10:56 +0200 Subject: [PATCH 5/6] refactor: max coords to vector --- src/managers/PointerManager.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp index ab9e4785999..47f854ba8f8 100644 --- a/src/managers/PointerManager.cpp +++ b/src/managers/PointerManager.cpp @@ -637,11 +637,10 @@ 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); + auto maxPoint = Vector2D{std::nextafter(b.x + b.w, -INFINITY), std::nextafter(b.y + b.h, -INFINITY)}; - // because closestPoint does clamp up to x + w and y + h - p = Vector2D{std::clamp(p.x, b.x, max_x), std::clamp(p.y, b.y, max_y)}; + // because closestPoint clamps up to x + w and y + h + p = Vector2D{std::clamp(p.x, b.x, maxPoint.x), std::clamp(p.y, b.y, maxPoint.y)}; auto distSq = p.distanceSq(vec); From 0029e558e982aba6813be207ada1dd4fa9cef855 Mon Sep 17 00:00:00 2001 From: drendog <53359960+drendog@users.noreply.github.com> Date: Mon, 1 Jul 2024 23:12:30 +0200 Subject: [PATCH 6/6] fix: remove box closestPoint adjustment due its fix on hyprutils --- src/managers/PointerManager.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp index 47f854ba8f8..973b7e27196 100644 --- a/src/managers/PointerManager.cpp +++ b/src/managers/PointerManager.cpp @@ -635,13 +635,7 @@ Vector2D CPointerManager::closestValid(const Vector2D& pos) { float distanceSq = __FLT_MAX__; for (auto& b : currentMonitorLayout.monitorBoxes) { - auto p = b.closestPoint(vec); - - auto maxPoint = Vector2D{std::nextafter(b.x + b.w, -INFINITY), std::nextafter(b.y + b.h, -INFINITY)}; - - // because closestPoint clamps up to x + w and y + h - p = Vector2D{std::clamp(p.x, b.x, maxPoint.x), std::clamp(p.y, b.y, maxPoint.y)}; - + auto p = b.closestPoint(vec); auto distSq = p.distanceSq(vec); if (distSq < distanceSq) {