aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorVaxry <[email protected]>2024-03-09 18:00:37 +0000
committerVaxry <[email protected]>2024-03-09 18:00:37 +0000
commit7e41e5146d124aa1161a73c249d41ad60f1bb162 (patch)
tree90728f3b41a1679f427d943ff578560aab80b640
parentc3882bb83240b602277f2d22f21d71690531f62e (diff)
downloadHyprland-7e41e5146d124aa1161a73c249d41ad60f1bb162.tar.gz
Hyprland-7e41e5146d124aa1161a73c249d41ad60f1bb162.zip
cursormgr: add fallbacks for unknown cursors
-rw-r--r--src/managers/CursorManager.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/managers/CursorManager.cpp b/src/managers/CursorManager.cpp
index ae765016..dc62bb74 100644
--- a/src/managers/CursorManager.cpp
+++ b/src/managers/CursorManager.cpp
@@ -107,8 +107,20 @@ void CCursorManager::setCursorFromName(const std::string& name) {
m_sCurrentCursorShapeData = m_pHyprcursor->getShape(name.c_str(), m_sCurrentStyleInfo);
if (m_sCurrentCursorShapeData.images.size() < 1) {
- Debug::log(ERR, "BUG THIS: No cursor returned by getShape()");
- return;
+ // fallback to a default if available
+ constexpr const std::array<const char*, 2> fallbackShapes = {"default", "left_ptr"};
+
+ for (auto& s : fallbackShapes) {
+ m_sCurrentCursorShapeData = m_pHyprcursor->getShape(s, m_sCurrentStyleInfo);
+
+ if (m_sCurrentCursorShapeData.images.size() > 0)
+ break;
+ }
+
+ if (m_sCurrentCursorShapeData.images.size() < 1) {
+ Debug::log(ERR, "BUG THIS: No fallback found for a cursor in setCursorFromName");
+ return;
+ }
}
m_vCursorBuffers.emplace_back(std::make_unique<CCursorBuffer>(m_sCurrentCursorShapeData.images[0].surface,