add static hover

This commit is contained in:
Felix Salcher 2025-07-12 14:00:24 +02:00
parent d5e49522e8
commit 2a4838da90
No known key found for this signature in database
5 changed files with 9 additions and 15 deletions

View file

@ -732,22 +732,19 @@ void CHyprlock::onHover(const Vector2D& pos) {
const auto widgets = g_pRenderer->getOrCreateWidgetsFor(*m_focusedOutput->m_sessionLockSurface);
for (const auto& widget : widgets) {
const bool CONTAINSPOINT = widget->containsPoint(SCALEDPOS);
const bool HOVERED = widget->isHovered();
const bool SHOULDHOVER = !widget->staticHover() || !widget->isHovered();
if (CONTAINSPOINT) {
if (!HOVERED) {
if (SHOULDHOVER) {
widget->setHover(true);
widget->onHover(pos);
widget->onPointerMove(pos);
outputNeedsRedraw = true;
} else {
outputNeedsRedraw |= widget->onPointerMove(pos);
}
if (!cursorChanged)
cursorChanged = true;
} else if (HOVERED) {
} else if (widget->isHovered()) {
widget->setHover(false);
outputNeedsRedraw = true;
}

View file

@ -275,8 +275,8 @@ bool IWidget::isHovered() const {
return hovered;
}
bool IWidget::onPointerMove(const Vector2D& pos) {
return false;
bool IWidget::staticHover() const {
return true;
}
bool IWidget::containsPoint(const Vector2D& pos) const {

View file

@ -29,7 +29,7 @@ class IWidget {
};
virtual void onClick(uint32_t button, bool down, const Vector2D& pos) {}
virtual void onHover(const Vector2D& pos) {}
virtual bool onPointerMove(const Vector2D& pos);
virtual bool staticHover() const;
bool containsPoint(const Vector2D& pos) const;
struct SFormatResult {

View file

@ -629,19 +629,16 @@ CBox CPasswordInputField::getEyeBox() {
}
void CPasswordInputField::onHover(const Vector2D& pos) {
g_pSeatManager->m_pCursorShape->setShape(WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_TEXT);
}
bool CPasswordInputField::onPointerMove(const Vector2D& pos) {
CBox eyeBox = getEyeBox();
if (eyeBox.containsPoint(pos)) {
g_pSeatManager->m_pCursorShape->setShape(WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_POINTER);
return true;
} else {
g_pSeatManager->m_pCursorShape->setShape(WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_TEXT);
}
}
bool CPasswordInputField::staticHover() const {
return false;
}

View file

@ -24,7 +24,7 @@ class CPasswordInputField : public IWidget {
virtual void configure(const std::unordered_map<std::string, std::any>& prop, const SP<COutput>& pOutput);
virtual bool draw(const SRenderData& data);
virtual void onHover(const Vector2D& pos);
virtual bool onPointerMove(const Vector2D& pos);
virtual bool staticHover() const;
virtual void onClick(uint32_t button, bool down, const Vector2D& pos);
virtual CBox getBoundingBoxWl() const;