mirror of
https://github.com/hyprwm/hyprlock.git
synced 2026-05-08 22:08:02 +02:00
add static hover
This commit is contained in:
parent
d5e49522e8
commit
2a4838da90
5 changed files with 9 additions and 15 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue