summaryrefslogtreecommitdiff
path: root/src/managers/input/InputManager.cpp
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2023-07-24 18:50:17 +0200
committervaxerski <43317083+vaxerski@users.noreply.github.com>2023-07-24 18:50:17 +0200
commitf5913135c638997f8c13a52d0760803947ae3889 (patch)
tree001ee05c5414d2d6d311d01427578dd352a31bb4 /src/managers/input/InputManager.cpp
parent76d4a50af3db7f2123d580eb7520f5b2956f261f (diff)
input: add support for cursor-shape-v1
Diffstat (limited to 'src/managers/input/InputManager.cpp')
-rw-r--r--src/managers/input/InputManager.cpp43
1 files changed, 31 insertions, 12 deletions
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;
}