mirror of
https://github.com/hyprwm/Hyprland
synced 2026-05-03 14:18:10 +02:00
Tablet: added option to hide cursor
This commit is contained in:
parent
bb963fb002
commit
39bfff659f
5 changed files with 17 additions and 2 deletions
|
|
@ -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});
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
|
||||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -155,6 +155,7 @@ class CHyprRenderer {
|
|||
|
||||
struct {
|
||||
bool hiddenOnTouch = false;
|
||||
bool hiddenOnPen = false;
|
||||
bool hiddenOnTimeout = false;
|
||||
bool hiddenOnKeyboard = false;
|
||||
} m_cursorHiddenConditions;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue