diff options
| author | Vaxry <vaxry@vaxry.net> | 2024-03-09 21:54:33 +0000 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2024-03-09 21:54:33 +0000 |
| commit | 739c5bc98c6037101e5744827dd66e696a4e9ecd (patch) | |
| tree | 744f2df98151a137af6d26b073d07c47f6ecfb1c /src/managers/CursorManager.cpp | |
| parent | 26cd1bf949d0460b754fe3b1ae7f06bd4b2535ee (diff) | |
cursormgr: fix invalid access to hyprcursor in xwayland init
fixes #5048
Diffstat (limited to 'src/managers/CursorManager.cpp')
| -rw-r--r-- | src/managers/CursorManager.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/managers/CursorManager.cpp b/src/managers/CursorManager.cpp index ff644010..2467b593 100644 --- a/src/managers/CursorManager.cpp +++ b/src/managers/CursorManager.cpp @@ -167,6 +167,10 @@ void CCursorManager::tickAnimatedCursor() { } SCursorImageData CCursorManager::dataFor(const std::string& name) { + + if (!m_pHyprcursor->valid()) + return {}; + const auto IMAGES = m_pHyprcursor->getShape(name.c_str(), m_sCurrentStyleInfo); if (IMAGES.images.empty()) @@ -175,6 +179,18 @@ SCursorImageData CCursorManager::dataFor(const std::string& name) { return IMAGES.images[0]; } +void CCursorManager::setXWaylandCursor(wlr_xwayland* xwayland) { + const auto CURSOR = dataFor("left_ptr"); + if (CURSOR.surface) { + wlr_xwayland_set_cursor(xwayland, cairo_image_surface_get_data(CURSOR.surface), cairo_image_surface_get_stride(CURSOR.surface), CURSOR.size, CURSOR.size, CURSOR.hotspotX, + CURSOR.hotspotY); + } else if (const auto XCURSOR = wlr_xcursor_manager_get_xcursor(m_pWLRXCursorMgr, "left_ptr", 1); XCURSOR) { + wlr_xwayland_set_cursor(xwayland, XCURSOR->images[0]->buffer, XCURSOR->images[0]->width * 4, XCURSOR->images[0]->width, XCURSOR->images[0]->height, + XCURSOR->images[0]->hotspot_x, XCURSOR->images[0]->hotspot_y); + } else + Debug::log(ERR, "CursorManager: no valid cursor for xwayland"); +} + void CCursorManager::updateTheme() { float highestScale = 1.0; |
