mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 16:05:58 +01:00
cursormgr: add fallbacks for unknown cursors
This commit is contained in:
parent
c3882bb832
commit
7e41e5146d
1 changed files with 14 additions and 2 deletions
|
@ -107,9 +107,21 @@ void CCursorManager::setCursorFromName(const std::string& name) {
|
||||||
m_sCurrentCursorShapeData = m_pHyprcursor->getShape(name.c_str(), m_sCurrentStyleInfo);
|
m_sCurrentCursorShapeData = m_pHyprcursor->getShape(name.c_str(), m_sCurrentStyleInfo);
|
||||||
|
|
||||||
if (m_sCurrentCursorShapeData.images.size() < 1) {
|
if (m_sCurrentCursorShapeData.images.size() < 1) {
|
||||||
Debug::log(ERR, "BUG THIS: No cursor returned by getShape()");
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_vCursorBuffers.emplace_back(std::make_unique<CCursorBuffer>(m_sCurrentCursorShapeData.images[0].surface,
|
m_vCursorBuffers.emplace_back(std::make_unique<CCursorBuffer>(m_sCurrentCursorShapeData.images[0].surface,
|
||||||
Vector2D{m_sCurrentCursorShapeData.images[0].size, m_sCurrentCursorShapeData.images[0].size},
|
Vector2D{m_sCurrentCursorShapeData.images[0].size, m_sCurrentCursorShapeData.images[0].size},
|
||||||
|
|
Loading…
Reference in a new issue