Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/config/ConfigDescriptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,12 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
.type = CONFIG_OPTION_BOOL,
.data = SConfigOptionDescription::SBoolData{true},
},
SConfigOptionDescription{
.value = "cursor:hide_on_pen",
.description = "Hides the cursor when the last input was a pen 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",
Expand Down
1 change: 1 addition & 0 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,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_pen", Hyprlang::INT{0});
registerConfigVar("cursor:use_cpu_buffer", Hyprlang::INT{2});
registerConfigVar("cursor:warp_back_after_non_mouse_input", Hyprlang::INT{0});

Expand Down
3 changes: 3 additions & 0 deletions src/managers/input/InputManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ class CInputManager {
// for hiding cursor on touch
bool m_lastInputTouch = false;

// for hiding cursor when using a pen
bool m_lastInputPen = false;

// for tracking mouse refocus
PHLWINDOWREF m_lastMouseFocus;

Expand Down
4 changes: 4 additions & 0 deletions src/managers/input/Tablets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ void CInputManager::onTabletAxis(CTablet::SAxisEvent e) {
}

void CInputManager::onTabletTip(CTablet::STipEvent e) {
m_lastInputPen = true;

EMIT_HOOK_EVENT_CANCELLABLE("tabletTip", e);

const auto PTAB = e.tablet;
Expand Down Expand Up @@ -214,9 +216,11 @@ void CInputManager::onTabletProximity(CTablet::SProximityEvent e) {
PTOOL->m_active = e.in;

if (!e.in) {
m_lastInputPen = false;
if (PTOOL->getSurface())
unfocusTool(PTOOL);
} else {
m_lastInputPen = true;
simulateMouseMovement();
refocusTablet(PTAB, PTOOL);
}
Expand Down
10 changes: 8 additions & 2 deletions src/render/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,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.hiddenOnPen == g_pInputManager->m_lastInputPen && !m_cursorHiddenConditions.hiddenOnTimeout)
return;

m_cursorHiddenConditions.hiddenOnKeyboard = false;
m_cursorHiddenConditions.hiddenOnTimeout = false;
m_cursorHiddenConditions.hiddenOnTouch = g_pInputManager->m_lastInputTouch;
m_cursorHiddenConditions.hiddenOnPen = g_pInputManager->m_lastInputPen;
ensureCursorRenderingMode();
});

Expand Down Expand Up @@ -2148,19 +2150,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 PHIDEONPEN = CConfigValue<Hyprlang::INT>("cursor:hide_on_pen");
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 (*PHIDEONPEN == 0)
m_cursorHiddenConditions.hiddenOnPen = 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.hiddenOnPen || m_cursorHiddenConditions.hiddenOnKeyboard;

const bool HIDE = m_cursorHiddenByCondition || (*PINVISIBLE != 0);

Expand Down
1 change: 1 addition & 0 deletions src/render/Renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class CHyprRenderer {

struct {
bool hiddenOnTouch = false;
bool hiddenOnPen = false;
bool hiddenOnTimeout = false;
bool hiddenOnKeyboard = false;
} m_cursorHiddenConditions;
Expand Down
Loading