diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 8e1eb3ad..b9301531 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -61,6 +61,7 @@ void CConfigManager::setDefaultVars() { configValues["misc:swallow_regex"].strValue = STRVAL_EMPTY; configValues["misc:focus_on_activate"].intValue = 0; configValues["misc:no_direct_scanout"].intValue = 0; + configValues["misc:hide_cursor_on_touch"].intValue = 1; configValues["debug:int"].intValue = 0; configValues["debug:log_damage"].intValue = 0; @@ -1342,12 +1343,8 @@ SConfigValue CConfigManager::getConfigValueSafeDevice(const std::string& dev, co if (foundIt == std::string::npos) continue; - if (cv.first == "input:" + val - || cv.first == "input:touchpad:" + cv.first - || cv.first == "input:touchdevice:" + val - || cv.first == "input:tablet:" + cv.first - || cv.first == "input:tablet:" + val - ) { + if (cv.first == "input:" + val || cv.first == "input:touchpad:" + cv.first || cv.first == "input:touchdevice:" + val || cv.first == "input:tablet:" + cv.first || + cv.first == "input:tablet:" + val) { copy = cv.second; } } diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index d1f24884..4f201677 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -21,6 +21,8 @@ void CInputManager::onMouseMoved(wlr_pointer_motion_event* e) { mouseMoveUnified(e->time_msec); m_tmrLastCursorMovement.reset(); + + m_bLastInputTouch = false; } void CInputManager::onMouseWarp(wlr_pointer_motion_absolute_event* e) { @@ -29,6 +31,8 @@ void CInputManager::onMouseWarp(wlr_pointer_motion_absolute_event* e) { mouseMoveUnified(e->time_msec); m_tmrLastCursorMovement.reset(); + + m_bLastInputTouch = false; } void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp index 8e4223eb..ec495d69 100644 --- a/src/managers/input/InputManager.hpp +++ b/src/managers/input/InputManager.hpp @@ -26,24 +26,22 @@ struct STouchData { }; // The third row is always 0 0 1 and is not expected by `libinput_device_config_calibration_set_matrix` -static const float MATRICES[8][6] = { - {// normal - 1, 0, 0, 0, 1, 0}, - {// rotation 90° - 0, -1, 1, 1, 0, 0}, - {// rotation 180° - -1, 0, 1, 0, -1, 1}, - {// rotation 270° - 0, 1, 0, -1, 0, 1}, - {// flipped - -1, 0, 1, 0, 1, 0}, - {// flipped + rotation 90° - 0, 1, 0, 1, 0, 0}, - {// flipped + rotation 180° - 1, 0, 0, 0, -1, 1}, - {// flipped + rotation 270° - 0, -1, 1, -1, 0, 1} -}; +static const float MATRICES[8][6] = {{// normal + 1, 0, 0, 0, 1, 0}, + {// rotation 90° + 0, -1, 1, 1, 0, 0}, + {// rotation 180° + -1, 0, 1, 0, -1, 1}, + {// rotation 270° + 0, 1, 0, -1, 0, 1}, + {// flipped + -1, 0, 1, 0, 1, 0}, + {// flipped + rotation 90° + 0, 1, 0, 1, 0, 0}, + {// flipped + rotation 180° + 1, 0, 0, 0, -1, 1}, + {// flipped + rotation 270° + 0, -1, 1, -1, 0, 1}}; class CKeybindManager; @@ -160,6 +158,9 @@ class CInputManager { // for some bugs in follow mouse 0 bool m_bLastFocusOnLS = false; + // for hiding cursor on touch + bool m_bLastInputTouch = false; + private: bool m_bCursorImageOverriden = false; diff --git a/src/managers/input/Touch.cpp b/src/managers/input/Touch.cpp index 984e0019..b69b4f7b 100644 --- a/src/managers/input/Touch.cpp +++ b/src/managers/input/Touch.cpp @@ -15,6 +15,8 @@ void CInputManager::onTouchDown(wlr_touch_down_event* e) { refocus(); + m_bLastInputTouch = true; + m_sTouchData.touchFocusWindow = m_pFoundWindowToFocus; m_sTouchData.touchFocusSurface = m_pFoundSurfaceToFocus; m_sTouchData.touchFocusLS = m_pFoundLSToFocus; diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 669b173f..b1e27092 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -1463,11 +1463,14 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR void CHyprRenderer::ensureCursorRenderingMode() { static auto* const PCURSORTIMEOUT = &g_pConfigManager->getConfigValuePtr("general:cursor_inactive_timeout")->intValue; + static auto* const PHIDEONTOUCH = &g_pConfigManager->getConfigValuePtr("misc:hide_cursor_on_touch")->intValue; const auto PASSEDCURSORSECONDS = g_pInputManager->m_tmrLastCursorMovement.getSeconds(); - if (*PCURSORTIMEOUT > 0) { - if (*PCURSORTIMEOUT < PASSEDCURSORSECONDS && m_bHasARenderedCursor) { + if (*PCURSORTIMEOUT > 0 || *PHIDEONTOUCH) { + const bool HIDE = (*PCURSORTIMEOUT > 0 && *PCURSORTIMEOUT < PASSEDCURSORSECONDS) || (g_pInputManager->m_bLastInputTouch && *PHIDEONTOUCH); + + if (HIDE && m_bHasARenderedCursor) { m_bHasARenderedCursor = false; wlr_cursor_set_surface(g_pCompositor->m_sWLRCursor, nullptr, 0, 0); // hide @@ -1476,7 +1479,7 @@ void CHyprRenderer::ensureCursorRenderingMode() { for (auto& m : g_pCompositor->m_vMonitors) g_pHyprRenderer->damageMonitor(m.get()); // TODO: maybe just damage the cursor area? - } else if (*PCURSORTIMEOUT > PASSEDCURSORSECONDS && !m_bHasARenderedCursor) { + } else if (!HIDE && !m_bHasARenderedCursor) { m_bHasARenderedCursor = true; if (!m_bWindowRequestedCursorHide)