From 868e85e36284f59cab620dfec00f20f135dff02a Mon Sep 17 00:00:00 2001 From: Vaxry Date: Tue, 20 Feb 2024 02:54:19 +0000 Subject: [PATCH] config: add general:hide_cursor --- src/config/ConfigManager.cpp | 1 + src/core/CursorShape.cpp | 4 ++++ src/core/CursorShape.hpp | 1 + src/core/hyprlock.cpp | 7 ++++++- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index e1b8fec..7be3c8b 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -20,6 +20,7 @@ CConfigManager::CConfigManager() : m_config(getMainConfigPath().c_str(), Hyprlan void CConfigManager::init() { m_config.addConfigValue("general:disable_loading_bar", Hyprlang::INT{0}); + m_config.addConfigValue("general:hide_cursor", Hyprlang::INT{0}); m_config.addSpecialCategory("background", Hyprlang::SSpecialCategoryOptions{.key = nullptr, .anonymousKeyBased = true}); m_config.addSpecialConfigValue("background", "monitor", Hyprlang::STRING{""}); diff --git a/src/core/CursorShape.cpp b/src/core/CursorShape.cpp index 365348d..ff91f9a 100644 --- a/src/core/CursorShape.cpp +++ b/src/core/CursorShape.cpp @@ -13,4 +13,8 @@ void CCursorShape::setShape(const uint32_t serial, const wp_cursor_shape_device_ return; wp_cursor_shape_device_v1_set_shape(dev, serial, shape); +} + +void CCursorShape::hideCursor(const uint32_t serial) { + wl_pointer_set_cursor(g_pHyprlock->m_pPointer, serial, nullptr, 0, 0); } \ No newline at end of file diff --git a/src/core/CursorShape.hpp b/src/core/CursorShape.hpp index 65b0f39..fd00df0 100644 --- a/src/core/CursorShape.hpp +++ b/src/core/CursorShape.hpp @@ -8,6 +8,7 @@ class CCursorShape { CCursorShape(wp_cursor_shape_manager_v1* mgr); void setShape(const uint32_t serial, const wp_cursor_shape_device_v1_shape shape); + void hideCursor(const uint32_t serial); private: wp_cursor_shape_manager_v1* mgr = nullptr; diff --git a/src/core/hyprlock.cpp b/src/core/hyprlock.cpp index a38eecc..52ecfeb 100644 --- a/src/core/hyprlock.cpp +++ b/src/core/hyprlock.cpp @@ -255,7 +255,12 @@ static void handlePointerEnter(void* data, struct wl_pointer* wl_pointer, uint32 if (!g_pHyprlock->m_pCursorShape) return; - g_pHyprlock->m_pCursorShape->setShape(serial, wp_cursor_shape_device_v1_shape::WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_POINTER); + static auto* const PHIDE = (Hyprlang::INT* const*)g_pConfigManager->getValuePtr("general:hide_cursor"); + + if (**PHIDE) + g_pHyprlock->m_pCursorShape->hideCursor(serial); + else + g_pHyprlock->m_pCursorShape->setShape(serial, wp_cursor_shape_device_v1_shape::WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_POINTER); } static void handlePointerLeave(void* data, struct wl_pointer* wl_pointer, uint32_t serial, struct wl_surface* surface) {