summaryrefslogtreecommitdiff
path: root/src/desktop
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2026-04-29 17:25:21 +0100
committerVaxry <43317083+vaxerski@users.noreply.github.com>2026-04-29 22:05:32 +0100
commit55a1611fd8150d7bb8d1b6e2b8cc95ffccf31ea2 (patch)
tree88ae2d9bcee6d327c6af97e2afb920020f16432b /src/desktop
parenta92dae5af7bad3af53f6d6b689d71ee900077569 (diff)
desktop/window: expand hidden into proper states
Diffstat (limited to 'src/desktop')
-rw-r--r--src/desktop/Workspace.cpp8
-rw-r--r--src/desktop/view/Group.cpp13
-rw-r--r--src/desktop/view/Window.cpp45
-rw-r--r--src/desktop/view/Window.hpp22
4 files changed, 71 insertions, 17 deletions
diff --git a/src/desktop/Workspace.cpp b/src/desktop/Workspace.cpp
index cb2da6b3..e6f0c306 100644
--- a/src/desktop/Workspace.cpp
+++ b/src/desktop/Workspace.cpp
@@ -426,7 +426,7 @@ int CWorkspace::getWindows(std::optional<bool> onlyTiled, std::optional<bool> on
continue;
if (onlyPinned.has_value() && (!t->window() || t->window()->m_pinned != onlyPinned.value()))
continue;
- if (onlyVisible.has_value() && (!t->window() || t->window()->isHidden() == onlyVisible.value()))
+ if (onlyVisible.has_value() && (!t->window() || t->window()->visible() != onlyVisible.value()))
continue;
no++;
}
@@ -445,7 +445,7 @@ int CWorkspace::getGroups(std::optional<bool> onlyTiled, std::optional<bool> onl
continue;
if (onlyPinned.has_value() && HEAD->m_pinned != onlyPinned.value())
continue;
- if (onlyVisible.has_value() && g->current()->isHidden() == onlyVisible.value())
+ if (onlyVisible.has_value() && g->current()->visible() != onlyVisible.value())
continue;
no++;
}
@@ -454,7 +454,7 @@ int CWorkspace::getGroups(std::optional<bool> onlyTiled, std::optional<bool> onl
PHLWINDOW CWorkspace::getFirstWindow() {
for (auto const& w : g_pCompositor->m_windows) {
- if (w->m_workspace == m_self && w->m_isMapped && !w->isHidden())
+ if (w->m_workspace == m_self && w->m_isMapped && w->acceptsInput())
return w;
}
@@ -465,7 +465,7 @@ PHLWINDOW CWorkspace::getTopLeftWindow() {
const auto PMONITOR = m_monitor.lock();
for (auto const& w : g_pCompositor->m_windows) {
- if (w->m_workspace != m_self || !w->m_isMapped || w->isHidden())
+ if (w->m_workspace != m_self || !w->m_isMapped || !w->acceptsInput())
continue;
const auto WINDOWIDEALBB = w->getWindowIdealBoundingBoxIgnoreReserved();
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<CXWaylandSurface> 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<CXDGSurfaceResource> 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<CBox> 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<uint32_t>(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<uint32_t>(reason)) != 0;
+}
+
+bool CWindow::acceptsInput() const {
+ return !isHidden() && !isInputBlocked();
+}
+
PHLANIMVAR<float>& 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<eFocusReason>(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<float>& alpha(eWindowAlpha type);
const PHLANIMVAR<float>& 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) {