tablet: added option to hide cursor (#12525)

This commit is contained in:
fuyu147 2025-12-19 11:14:22 -05:00 committed by GitHub
parent 6175ecd4c4
commit 315806f598
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 25 additions and 4 deletions

View file

@ -1682,6 +1682,12 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
.type = CONFIG_OPTION_BOOL,
.data = SConfigOptionDescription::SBoolData{true},
},
SConfigOptionDescription{
.value = "cursor:hide_on_tablet",
.description = "Hides the cursor when the last input was a tablet input until a mouse input is done.",
.type = CONFIG_OPTION_BOOL,
.data = SConfigOptionDescription::SBoolData{true},
},
SConfigOptionDescription{
.value = "cursor:use_cpu_buffer",
.description = "Makes HW cursors use a CPU buffer. Required on Nvidia to have HW cursors. Experimental",

View file

@ -739,6 +739,7 @@ CConfigManager::CConfigManager() {
registerConfigVar("cursor:sync_gsettings_theme", Hyprlang::INT{1});
registerConfigVar("cursor:hide_on_key_press", Hyprlang::INT{0});
registerConfigVar("cursor:hide_on_touch", Hyprlang::INT{1});
registerConfigVar("cursor:hide_on_tablet", Hyprlang::INT{0});
registerConfigVar("cursor:use_cpu_buffer", Hyprlang::INT{2});
registerConfigVar("cursor:warp_back_after_non_mouse_input", Hyprlang::INT{0});

View file

@ -147,6 +147,7 @@ void CInputManager::onMouseMoved(IPointer::SMotionEvent e) {
m_lastCursorMovement.reset();
m_lastInputTouch = false;
m_lastInputTablet = false;
if (e.mouse)
m_lastMousePos = getMouseCoordsInternal();
@ -160,6 +161,7 @@ void CInputManager::onMouseWarp(IPointer::SMotionAbsoluteEvent e) {
m_lastCursorMovement.reset();
m_lastInputTouch = false;
m_lastInputTablet = false;
}
void CInputManager::simulateMouseMovement() {

View file

@ -208,6 +208,9 @@ class CInputManager {
// for hiding cursor on touch
bool m_lastInputTouch = false;
// for hiding cursor on tablet
bool m_lastInputTablet = false;
// for tracking mouse refocus
PHLWINDOWREF m_lastMouseFocus;

View file

@ -216,9 +216,11 @@ void CInputManager::onTabletProximity(CTablet::SProximityEvent e) {
PTOOL->m_active = e.in;
if (!e.in) {
m_lastInputTablet = false;
if (PTOOL->getSurface())
unfocusTool(PTOOL);
} else {
m_lastInputTablet = true;
simulateMouseMovement();
refocusTablet(PTAB, PTOOL);
}

View file

@ -121,12 +121,14 @@ CHyprRenderer::CHyprRenderer() {
});
static auto P2 = g_pHookSystem->hookDynamic("mouseMove", [&](void* self, SCallbackInfo& info, std::any param) {
if (!m_cursorHiddenConditions.hiddenOnKeyboard && m_cursorHiddenConditions.hiddenOnTouch == g_pInputManager->m_lastInputTouch && !m_cursorHiddenConditions.hiddenOnTimeout)
if (!m_cursorHiddenConditions.hiddenOnKeyboard && m_cursorHiddenConditions.hiddenOnTouch == g_pInputManager->m_lastInputTouch &&
m_cursorHiddenConditions.hiddenOnTablet == g_pInputManager->m_lastInputTablet && !m_cursorHiddenConditions.hiddenOnTimeout)
return;
m_cursorHiddenConditions.hiddenOnKeyboard = false;
m_cursorHiddenConditions.hiddenOnTimeout = false;
m_cursorHiddenConditions.hiddenOnTouch = g_pInputManager->m_lastInputTouch;
m_cursorHiddenConditions.hiddenOnTablet = g_pInputManager->m_lastInputTablet;
ensureCursorRenderingMode();
});
@ -2111,19 +2113,23 @@ void CHyprRenderer::ensureCursorRenderingMode() {
static auto PINVISIBLE = CConfigValue<Hyprlang::INT>("cursor:invisible");
static auto PCURSORTIMEOUT = CConfigValue<Hyprlang::FLOAT>("cursor:inactive_timeout");
static auto PHIDEONTOUCH = CConfigValue<Hyprlang::INT>("cursor:hide_on_touch");
static auto PHIDEONTABLET = CConfigValue<Hyprlang::INT>("cursor:hide_on_tablet");
static auto PHIDEONKEY = CConfigValue<Hyprlang::INT>("cursor:hide_on_key_press");
if (*PCURSORTIMEOUT <= 0)
m_cursorHiddenConditions.hiddenOnTimeout = false;
if (*PHIDEONTOUCH == 0)
m_cursorHiddenConditions.hiddenOnTouch = false;
if (*PHIDEONTABLET == 0)
m_cursorHiddenConditions.hiddenOnTablet = false;
if (*PHIDEONKEY == 0)
m_cursorHiddenConditions.hiddenOnKeyboard = false;
if (*PCURSORTIMEOUT > 0)
m_cursorHiddenConditions.hiddenOnTimeout = *PCURSORTIMEOUT < g_pInputManager->m_lastCursorMovement.getSeconds();
m_cursorHiddenByCondition = m_cursorHiddenConditions.hiddenOnTimeout || m_cursorHiddenConditions.hiddenOnTouch || m_cursorHiddenConditions.hiddenOnKeyboard;
m_cursorHiddenByCondition =
m_cursorHiddenConditions.hiddenOnTimeout || m_cursorHiddenConditions.hiddenOnTouch || m_cursorHiddenConditions.hiddenOnTablet || m_cursorHiddenConditions.hiddenOnKeyboard;
const bool HIDE = m_cursorHiddenByCondition || (*PINVISIBLE != 0);

View file

@ -154,6 +154,7 @@ class CHyprRenderer {
struct {
bool hiddenOnTouch = false;
bool hiddenOnTablet = false;
bool hiddenOnTimeout = false;
bool hiddenOnKeyboard = false;
} m_cursorHiddenConditions;