From f5913135c638997f8c13a52d0760803947ae3889 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 24 Jul 2023 18:50:17 +0200 Subject: input: add support for cursor-shape-v1 --- src/managers/input/InputManager.cpp | 43 ++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 12 deletions(-) (limited to 'src/managers/input/InputManager.cpp') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 3a7a77f2..0b174737 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -464,23 +464,14 @@ void CInputManager::onMouseButton(wlr_pointer_button_event* e) { } void CInputManager::processMouseRequest(wlr_seat_pointer_request_set_cursor_event* e) { - if (!g_pHyprRenderer->shouldRenderCursor()) - return; - if (!e->surface) { + if (!e->surface) g_pHyprRenderer->m_bWindowRequestedCursorHide = true; - } else { + else g_pHyprRenderer->m_bWindowRequestedCursorHide = false; - } - if (m_bCursorImageOverridden) { + if (!cursorImageUnlocked()) return; - } - - if (m_ecbClickBehavior == CLICKMODE_KILL) { - wlr_cursor_set_xcursor(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sWLRXCursorMgr, "crosshair"); - return; - } // cursorSurfaceInfo.pSurface = e->surface; @@ -495,6 +486,34 @@ void CInputManager::processMouseRequest(wlr_seat_pointer_request_set_cursor_even wlr_cursor_set_surface(g_pCompositor->m_sWLRCursor, e->surface, e->hotspot_x, e->hotspot_y); } +void CInputManager::processMouseRequest(wlr_cursor_shape_manager_v1_request_set_shape_event* e) { + if (!g_pHyprRenderer->shouldRenderCursor()) + return; + + if (!g_pCompositor->m_pLastFocus) + return; + + if (wl_resource_get_client(g_pCompositor->m_pLastFocus->resource) != e->seat_client->client) { + Debug::log(ERR, "Disallowing cursor shape request from unfocused"); + return; + } + + wlr_cursor_set_xcursor(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sWLRXCursorMgr, wlr_cursor_shape_v1_name(e->shape)); +} + +bool CInputManager::cursorImageUnlocked() { + if (!g_pHyprRenderer->shouldRenderCursor()) + return false; + + if (m_ecbClickBehavior == CLICKMODE_KILL) + return false; + + if (m_bCursorImageOverridden) + return false; + + return true; +} + eClickBehaviorMode CInputManager::getClickMode() { return m_ecbClickBehavior; } -- cgit v1.2.3