From 55a1611fd8150d7bb8d1b6e2b8cc95ffccf31ea2 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Wed, 29 Apr 2026 17:25:21 +0100 Subject: desktop/window: expand hidden into proper states --- src/desktop/view/Group.cpp | 13 +++++++++---- src/desktop/view/Window.cpp | 45 ++++++++++++++++++++++++++++++++++++++++----- src/desktop/view/Window.hpp | 22 ++++++++++++++++++---- 3 files changed, 67 insertions(+), 13 deletions(-) (limited to 'src/desktop/view') diff --git a/src/desktop/view/Group.cpp b/src/desktop/view/Group.cpp index 464a38da..f2b2a564 100644 --- a/src/desktop/view/Group.cpp +++ b/src/desktop/view/Group.cpp @@ -142,7 +142,8 @@ void CGroup::remove(PHLWINDOW w, Math::eDirection dir) { w->m_group.reset(); removeWindowDecos(w); - w->setHidden(false); + w->setInputBlocked(INPUT_BLOCK_GROUP_INACTIVE, false); + *w->alpha(WINDOW_ALPHA_LAYOUT) = 1.F; const bool REMOVING_GROUP = m_windows.size() <= 1; @@ -280,12 +281,16 @@ void CGroup::updateWindowVisibility() { for (size_t i = 0; i < m_windows.size(); ++i) { if (i == m_current) { auto& x = m_windows.at(i); - x->setHidden(false); + x->setInputBlocked(INPUT_BLOCK_GROUP_INACTIVE, false); + *x->alpha(WINDOW_ALPHA_LAYOUT) = 1.F; x->m_ruleApplicator->propertiesChanged(Desktop::Rule::RULE_PROP_GROUP | Desktop::Rule::RULE_PROP_ON_WORKSPACE); x->updateWindowDecos(); x->updateDecorationValues(); - } else - m_windows.at(i)->setHidden(true); + } else { + auto& x = m_windows.at(i); + x->setInputBlocked(INPUT_BLOCK_GROUP_INACTIVE, true); + *x->alpha(WINDOW_ALPHA_LAYOUT) = 0.F; + } } m_target->recalc(); diff --git a/src/desktop/view/Window.cpp b/src/desktop/view/Window.cpp index ef854bd1..73c4378d 100644 --- a/src/desktop/view/Window.cpp +++ b/src/desktop/view/Window.cpp @@ -87,7 +87,7 @@ PHLWINDOW CWindow::create(SP surface) { g_pAnimationManager->createAnimation(1.f, pWindow->alpha(WINDOW_ALPHA_FADE), Config::animationTree()->getAnimationPropertyConfig("fadeIn"), pWindow, AVARDAMAGE_ENTIRE); g_pAnimationManager->createAnimation(1.f, pWindow->alpha(WINDOW_ALPHA_ACTIVE), Config::animationTree()->getAnimationPropertyConfig("fadeSwitch"), pWindow, AVARDAMAGE_ENTIRE); g_pAnimationManager->createAnimation(1.f, pWindow->alpha(WINDOW_ALPHA_FULLSCREEN), Config::animationTree()->getAnimationPropertyConfig("fadeIn"), pWindow, AVARDAMAGE_ENTIRE); - g_pAnimationManager->createAnimation(1.f, pWindow->alpha(WINDOW_ALPHA_LAYOUT), Config::animationTree()->getAnimationPropertyConfig("fadeIn"), pWindow, AVARDAMAGE_ENTIRE); + g_pAnimationManager->createAnimation(1.f, pWindow->alpha(WINDOW_ALPHA_LAYOUT), Config::animationTree()->getAnimationPropertyConfig("fadeSwitch"), pWindow, AVARDAMAGE_ENTIRE); g_pAnimationManager->createAnimation(CHyprColor(), pWindow->m_realShadowColor, Config::animationTree()->getAnimationPropertyConfig("fadeShadow"), pWindow, AVARDAMAGE_SHADOW); g_pAnimationManager->createAnimation(CHyprColor(), pWindow->m_realGlowColor, Config::animationTree()->getAnimationPropertyConfig("fadeGlow"), pWindow, AVARDAMAGE_ENTIRE); g_pAnimationManager->createAnimation(0.f, pWindow->m_dimPercent, Config::animationTree()->getAnimationPropertyConfig("fadeDim"), pWindow, AVARDAMAGE_ENTIRE); @@ -121,7 +121,7 @@ PHLWINDOW CWindow::create(SP resource) { g_pAnimationManager->createAnimation(1.f, pWindow->alpha(WINDOW_ALPHA_FADE), Config::animationTree()->getAnimationPropertyConfig("fadeIn"), pWindow, AVARDAMAGE_ENTIRE); g_pAnimationManager->createAnimation(1.f, pWindow->alpha(WINDOW_ALPHA_ACTIVE), Config::animationTree()->getAnimationPropertyConfig("fadeSwitch"), pWindow, AVARDAMAGE_ENTIRE); g_pAnimationManager->createAnimation(1.f, pWindow->alpha(WINDOW_ALPHA_FULLSCREEN), Config::animationTree()->getAnimationPropertyConfig("fadeIn"), pWindow, AVARDAMAGE_ENTIRE); - g_pAnimationManager->createAnimation(1.f, pWindow->alpha(WINDOW_ALPHA_LAYOUT), Config::animationTree()->getAnimationPropertyConfig("fadeIn"), pWindow, AVARDAMAGE_ENTIRE); + g_pAnimationManager->createAnimation(1.f, pWindow->alpha(WINDOW_ALPHA_LAYOUT), Config::animationTree()->getAnimationPropertyConfig("fadeSwitch"), pWindow, AVARDAMAGE_ENTIRE); g_pAnimationManager->createAnimation(CHyprColor(), pWindow->m_realShadowColor, Config::animationTree()->getAnimationPropertyConfig("fadeShadow"), pWindow, AVARDAMAGE_SHADOW); g_pAnimationManager->createAnimation(CHyprColor(), pWindow->m_realGlowColor, Config::animationTree()->getAnimationPropertyConfig("fadeGlow"), pWindow, AVARDAMAGE_ENTIRE); g_pAnimationManager->createAnimation(0.f, pWindow->m_dimPercent, Config::animationTree()->getAnimationPropertyConfig("fadeDim"), pWindow, AVARDAMAGE_ENTIRE); @@ -187,7 +187,7 @@ eViewType CWindow::type() const { } bool CWindow::visible() const { - return !m_hidden && ((m_isMapped && m_wlSurface && m_wlSurface->resource()) || (m_fadingOut && alphaValue(WINDOW_ALPHA_FADE) != 0.F)); + return !m_hidden && ((m_isMapped && m_wlSurface && m_wlSurface->resource()) || m_fadingOut) && visibleByAlpha(); } std::optional CWindow::logicalBox() const { @@ -723,10 +723,37 @@ void CWindow::setHidden(bool hidden) { setSuspended(hidden); } -bool CWindow::isHidden() { +bool CWindow::isHidden() const { return m_hidden; } +void CWindow::setInputBlocked(eWindowInputBlockReason reason, bool blocked) { + if (reason == INPUT_BLOCK_NONE) + return; + + const auto MASK = sc(reason); + + if (blocked) + m_inputBlockReasons |= MASK; + else + m_inputBlockReasons &= ~MASK; + + if (blocked && Desktop::focusState()->window() == m_self) + Desktop::focusState()->window().reset(); +} + +bool CWindow::isInputBlocked() const { + return m_inputBlockReasons != INPUT_BLOCK_NONE; +} + +bool CWindow::isInputBlocked(eWindowInputBlockReason reason) const { + return (m_inputBlockReasons & sc(reason)) != 0; +} + +bool CWindow::acceptsInput() const { + return !isHidden() && !isInputBlocked(); +} + PHLANIMVAR& CWindow::alpha(eWindowAlpha type) { return m_alpha.get(type); } @@ -751,6 +778,14 @@ float CWindow::alphaTotalWithout(eWindowAlpha type) const { return m_alpha.getTotalWithout(type); } +float CWindow::effectiveAlpha() const { + return alphaTotal(); +} + +bool CWindow::visibleByAlpha() const { + return effectiveAlpha() != 0.F; +} + // check if the point is "hidden" under a rounded corner of the window // it is assumed that the point is within the real window box (m_vRealPosition, m_vRealSize) // otherwise behaviour is undefined @@ -1341,7 +1376,7 @@ PHLWINDOW CWindow::getSwallower() { break; for (auto const& w : g_pCompositor->m_windows) { - if (!w->m_isMapped || w->isHidden()) + if (!w->m_isMapped || !w->acceptsInput()) continue; if (w->getPID() == currentPid) diff --git a/src/desktop/view/Window.hpp b/src/desktop/view/Window.hpp index 0a468ee3..a5d89c58 100644 --- a/src/desktop/view/Window.hpp +++ b/src/desktop/view/Window.hpp @@ -89,6 +89,13 @@ namespace Desktop::View { WINDOW_ALPHA_LAST, }; + enum eWindowInputBlockReason : uint32_t { + INPUT_BLOCK_NONE = 0, + INPUT_BLOCK_GROUP_INACTIVE = 1 << 0, + INPUT_BLOCK_MONOCLE_INACTIVE = 1 << 1, + INPUT_BLOCK_BELOW_FULLSCREEN = 1 << 2, + }; + struct SWindowActiveEvent { PHLWINDOW window = nullptr; eFocusReason reason = sc(0) /* unknown */; @@ -304,13 +311,19 @@ namespace Desktop::View { void onUnmap(); void onMap(); void setHidden(bool hidden); - bool isHidden(); + bool isHidden() const; + void setInputBlocked(eWindowInputBlockReason reason, bool blocked); + bool isInputBlocked() const; + bool isInputBlocked(eWindowInputBlockReason reason) const; + bool acceptsInput() const; PHLANIMVAR& alpha(eWindowAlpha type); const PHLANIMVAR& alpha(eWindowAlpha type) const; float alphaValue(eWindowAlpha type) const; float alphaGoal(eWindowAlpha type) const; float alphaTotal() const; float alphaTotalWithout(eWindowAlpha type) const; + float effectiveAlpha() const; + bool visibleByAlpha() const; void updateDecorationValues(); SBoxExtents getFullWindowReservedArea(); Vector2D middle(); @@ -414,9 +427,10 @@ namespace Desktop::View { void unmanagedSetGeometry(); // For hidden windows and stuff - bool m_hidden = false; - bool m_suspended = false; - WORKSPACEID m_lastWorkspace = WORKSPACE_INVALID; + bool m_hidden = false; + bool m_suspended = false; + WORKSPACEID m_lastWorkspace = WORKSPACE_INVALID; + uint32_t m_inputBlockReasons = INPUT_BLOCK_NONE; }; inline bool valid(PHLWINDOW w) { -- cgit v1.2.3