diff options
| author | Vaxry <vaxry@vaxry.net> | 2026-04-29 17:25:21 +0100 |
|---|---|---|
| committer | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2026-04-29 22:05:32 +0100 |
| commit | 55a1611fd8150d7bb8d1b6e2b8cc95ffccf31ea2 (patch) | |
| tree | 88ae2d9bcee6d327c6af97e2afb920020f16432b /src | |
| parent | a92dae5af7bad3af53f6d6b689d71ee900077569 (diff) | |
desktop/window: expand hidden into proper states
Diffstat (limited to 'src')
| -rw-r--r-- | src/Compositor.cpp | 19 | ||||
| -rw-r--r-- | src/config/lua/objects/LuaWindow.cpp | 4 | ||||
| -rw-r--r-- | src/debug/HyprCtl.cpp | 35 | ||||
| -rw-r--r-- | src/desktop/Workspace.cpp | 8 | ||||
| -rw-r--r-- | src/desktop/view/Group.cpp | 13 | ||||
| -rw-r--r-- | src/desktop/view/Window.cpp | 45 | ||||
| -rw-r--r-- | src/desktop/view/Window.hpp | 22 | ||||
| -rw-r--r-- | src/helpers/Monitor.cpp | 2 | ||||
| -rw-r--r-- | src/layout/algorithm/tiled/monocle/MonocleAlgorithm.cpp | 15 | ||||
| -rw-r--r-- | src/render/OpenGL.cpp | 2 | ||||
| -rw-r--r-- | src/render/Renderer.cpp | 3 |
11 files changed, 120 insertions, 48 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 3b7ea815..19fe6d75 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -927,7 +927,7 @@ PHLWINDOW CCompositor::vectorToWindowUnified(const Vector2D& pos, uint16_t prope if (ONLY_PRIORITY && !w->priorityFocus()) continue; - if (w->m_isFloating && w->m_isMapped && !w->isHidden() && !w->m_X11ShouldntFocus && w->m_pinned && !w->m_ruleApplicator->noFocus().valueOrDefault() && + if (w->m_isFloating && w->m_isMapped && w->acceptsInput() && !w->m_X11ShouldntFocus && w->m_pinned && !w->m_ruleApplicator->noFocus().valueOrDefault() && w != pIgnoreWindow && !isShadowedByModal(w)) { const auto BB = w->getWindowBoxUnified(properties); CBox box = BB.copy().expand(!w->isX11OverrideRedirect() ? BORDER_GRAB_AREA : 0); @@ -967,7 +967,7 @@ PHLWINDOW CCompositor::vectorToWindowUnified(const Vector2D& pos, uint16_t prope continue; } - if (w->m_isFloating && w->m_isMapped && w->m_workspace->isVisible() && !w->isHidden() && !w->m_pinned && !w->m_ruleApplicator->noFocus().valueOrDefault() && + if (w->m_isFloating && w->m_isMapped && w->m_workspace->isVisible() && w->acceptsInput() && !w->m_pinned && !w->m_ruleApplicator->noFocus().valueOrDefault() && w != pIgnoreWindow && (!aboveFullscreen || w->m_createdOverFullscreen) && !isShadowedByModal(w)) { // OR windows should add focus to parent if (w->m_X11ShouldntFocus && !w->isX11OverrideRedirect()) @@ -1039,7 +1039,7 @@ PHLWINDOW CCompositor::vectorToWindowUnified(const Vector2D& pos, uint16_t prope if (!w->m_workspace) continue; - if (!w->m_isX11 && !w->m_isFloating && w->m_isMapped && w->workspaceID() == WSPID && !w->isHidden() && !w->m_X11ShouldntFocus && + if (!w->m_isX11 && !w->m_isFloating && w->m_isMapped && w->workspaceID() == WSPID && w->acceptsInput() && !w->m_X11ShouldntFocus && !w->m_ruleApplicator->noFocus().valueOrDefault() && w != pIgnoreWindow && !isShadowedByModal(w)) { if (w->hasPopupAt(pos)) return w; @@ -1056,7 +1056,7 @@ PHLWINDOW CCompositor::vectorToWindowUnified(const Vector2D& pos, uint16_t prope if (!w->m_workspace) continue; - if (!w->m_isFloating && w->m_isMapped && w->workspaceID() == WSPID && !w->isHidden() && !w->m_X11ShouldntFocus && !w->m_ruleApplicator->noFocus().valueOrDefault() && + if (!w->m_isFloating && w->m_isMapped && w->workspaceID() == WSPID && w->acceptsInput() && !w->m_X11ShouldntFocus && !w->m_ruleApplicator->noFocus().valueOrDefault() && w != pIgnoreWindow && !isShadowedByModal(w)) { CBox box = (properties & Desktop::View::USE_PROP_TILED) ? w->getWindowBoxUnified(properties) : CBox{w->m_position, w->m_size}; if ((properties & Desktop::View::INPUT_EXTENTS) && BORDER_GRAB_AREA > 0 && !w->isX11OverrideRedirect()) { @@ -1515,7 +1515,7 @@ PHLWINDOW CCompositor::getWindowInDirection(const CBox& box, PHLWORKSPACE pWorks }; for (auto const& w : m_windows) { - if (w == ignoreWindow || !w->m_workspace || !w->m_isMapped || w->isHidden() || (!w->isFullscreen() && w->m_isFloating) || !w->m_workspace->isVisible()) + if (w == ignoreWindow || !w->m_workspace || !w->m_isMapped || !w->acceptsInput() || (!w->isFullscreen() && w->m_isFloating) || !w->m_workspace->isVisible()) continue; if (pWorkspace->m_monitor == w->m_monitor && pWorkspace != w->m_workspace) @@ -1594,7 +1594,7 @@ PHLWINDOW CCompositor::getWindowInDirection(const CBox& box, PHLWORKSPACE pWorks constexpr float THRESHOLD = 0.3 * M_PI; for (auto const& w : m_windows) { - if (w == ignoreWindow || !w->m_isMapped || !w->m_workspace || w->isHidden() || (!w->isFullscreen() && !w->m_isFloating) || !w->m_workspace->isVisible()) + if (w == ignoreWindow || !w->m_isMapped || !w->m_workspace || !w->acceptsInput() || (!w->isFullscreen() && !w->m_isFloating) || !w->m_workspace->isVisible()) continue; if (pWorkspace->m_monitor == w->m_monitor && pWorkspace != w->m_workspace) @@ -1642,7 +1642,8 @@ static bool isFloatingMatches(WINDOWPTR w, std::optional<bool> floating) { template <typename WINDOWPTR> static bool isWindowAvailableForCycle(WINDOWPTR pWindow, WINDOWPTR w, bool focusableOnly, std::optional<bool> floating, bool anyWorkspace = false) { return isFloatingMatches(w, floating) && - (w != pWindow && isWorkspaceMatches(pWindow, w, anyWorkspace) && w->m_isMapped && !w->isHidden() && (!focusableOnly || !w->m_ruleApplicator->noFocus().valueOrDefault())); + (w != pWindow && isWorkspaceMatches(pWindow, w, anyWorkspace) && w->m_isMapped && w->acceptsInput() && + (!focusableOnly || !w->m_ruleApplicator->noFocus().valueOrDefault())); } template <typename Iterator> @@ -2331,7 +2332,7 @@ PHLWINDOW CCompositor::getWindowByRegex(const std::string& regexp_) { const bool FLOAT = regexp.starts_with("floating"); for (auto const& w : m_windows) { - if (!w->m_isMapped || w->m_isFloating != FLOAT || w->m_workspace != Desktop::focusState()->window()->m_workspace || w->isHidden()) + if (!w->m_isMapped || w->m_isFloating != FLOAT || w->m_workspace != Desktop::focusState()->window()->m_workspace || !w->acceptsInput()) continue; return w; @@ -2708,7 +2709,7 @@ void CCompositor::moveWindowToWorkspaceSafe(PHLWINDOW pWindow, PHLWORKSPACE pWor PHLWINDOW CCompositor::getForceFocus() { for (auto const& w : m_windows) { - if (!w->m_isMapped || w->isHidden() || !w->m_workspace || !w->m_workspace->isVisible()) + if (!w->m_isMapped || !w->acceptsInput() || !w->m_workspace || !w->m_workspace->isVisible()) continue; if (!w->m_ruleApplicator->stayFocused().valueOrDefault()) diff --git a/src/config/lua/objects/LuaWindow.cpp b/src/config/lua/objects/LuaWindow.cpp index bf332584..b1a71aaa 100644 --- a/src/config/lua/objects/LuaWindow.cpp +++ b/src/config/lua/objects/LuaWindow.cpp @@ -71,6 +71,10 @@ static int windowIndex(lua_State* L) { lua_pushboolean(L, w->m_isMapped); else if (key == "hidden") lua_pushboolean(L, w->isHidden()); + else if (key == "visible") + lua_pushboolean(L, w->visible()); + else if (key == "acceptsInput") + lua_pushboolean(L, w->acceptsInput()); else if (key == "at") { lua_newtable(L); lua_pushinteger(L, sc<int>(w->m_realPosition->goal().x)); diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index 540a28e2..a3f5f9e0 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -382,6 +382,8 @@ std::string CHyprCtl::getWindowData(PHLWINDOW w, eHyprCtlOutputFormat format) { "address": "0x{:x}", "mapped": {}, "hidden": {}, + "visible": {}, + "acceptsInput": {}, "at": [{}, {}], "size": [{}, {}], "workspace": {{ @@ -410,28 +412,31 @@ std::string CHyprCtl::getWindowData(PHLWINDOW w, eHyprCtlOutputFormat format) { "contentType": "{}", "stableId": "{:x}" }},)#", - rc<uintptr_t>(w.get()), (w->m_isMapped ? "true" : "false"), (w->isHidden() ? "true" : "false"), sc<int>(w->m_realPosition->goal().x), - sc<int>(w->m_realPosition->goal().y), sc<int>(w->m_realSize->goal().x), sc<int>(w->m_realSize->goal().y), w->m_workspace ? w->workspaceID() : WORKSPACE_INVALID, - escapeJSONStrings(!w->m_workspace ? "" : w->m_workspace->m_name), (sc<int>(w->m_isFloating) == 1 ? "true" : "false"), w->monitorID(), escapeJSONStrings(w->m_class), - escapeJSONStrings(w->m_title), escapeJSONStrings(w->m_initialClass), escapeJSONStrings(w->m_initialTitle), w->getPID(), (sc<int>(w->m_isX11) == 1 ? "true" : "false"), - (w->m_pinned ? "true" : "false"), sc<uint8_t>(w->m_fullscreenState.internal), sc<uint8_t>(w->m_fullscreenState.client), (w->m_createdOverFullscreen ? "true" : "false"), - getGroupedData(w, format), getTagsData(w, format), rc<uintptr_t>(w->m_swallowed.get()), getFocusHistoryID(w), - (g_pInputManager->isWindowInhibiting(w, false) ? "true" : "false"), escapeJSONStrings(w->xdgTag().value_or("")), escapeJSONStrings(w->xdgDescription().value_or("")), - escapeJSONStrings(NContentType::toString(w->getContentType())), w->m_stableID); + rc<uintptr_t>(w.get()), (w->m_isMapped ? "true" : "false"), (w->isHidden() ? "true" : "false"), (w->visible() ? "true" : "false"), + (w->acceptsInput() ? "true" : "false"), sc<int>(w->m_realPosition->goal().x), sc<int>(w->m_realPosition->goal().y), sc<int>(w->m_realSize->goal().x), + sc<int>(w->m_realSize->goal().y), w->m_workspace ? w->workspaceID() : WORKSPACE_INVALID, escapeJSONStrings(!w->m_workspace ? "" : w->m_workspace->m_name), + (sc<int>(w->m_isFloating) == 1 ? "true" : "false"), w->monitorID(), escapeJSONStrings(w->m_class), escapeJSONStrings(w->m_title), escapeJSONStrings(w->m_initialClass), + escapeJSONStrings(w->m_initialTitle), w->getPID(), (sc<int>(w->m_isX11) == 1 ? "true" : "false"), (w->m_pinned ? "true" : "false"), + sc<uint8_t>(w->m_fullscreenState.internal), sc<uint8_t>(w->m_fullscreenState.client), (w->m_createdOverFullscreen ? "true" : "false"), getGroupedData(w, format), + getTagsData(w, format), rc<uintptr_t>(w->m_swallowed.get()), getFocusHistoryID(w), (g_pInputManager->isWindowInhibiting(w, false) ? "true" : "false"), + escapeJSONStrings(w->xdgTag().value_or("")), escapeJSONStrings(w->xdgDescription().value_or("")), escapeJSONStrings(NContentType::toString(w->getContentType())), + w->m_stableID); } else { return std::format( - "Window {:x} -> {}:\n\tmapped: {}\n\thidden: {}\n\tat: {},{}\n\tsize: {},{}\n\tworkspace: {} ({})\n\tfloating: {}\n\tmonitor: {}\n\tclass: {}\n\ttitle: " + "Window {:x} -> {}:\n\tmapped: {}\n\thidden: {}\n\tvisible: {}\n\tacceptsInput: {}\n\tat: {},{}\n\tsize: {},{}\n\tworkspace: {} ({})\n\tfloating: {}\n\tmonitor: " + "{}\n\tclass: {}\n\ttitle: " "{}\n\tinitialClass: {}\n\tinitialTitle: {}\n\tpid: " "{}\n\txwayland: {}\n\tpinned: " "{}\n\tfullscreen: {}\n\tfullscreenClient: {}\n\toverFullscreen: {}\n\tgrouped: {}\n\ttags: {}\n\tswallowing: {:x}\n\tfocusHistoryID: {}\n\tinhibitingIdle: " "{}\n\txdgTag: " "{}\n\txdgDescription: {}\n\tcontentType: {}\n\tstableID: {:x}\n\n", - rc<uintptr_t>(w.get()), w->m_title, sc<int>(w->m_isMapped), sc<int>(w->isHidden()), sc<int>(w->m_realPosition->goal().x), sc<int>(w->m_realPosition->goal().y), - sc<int>(w->m_realSize->goal().x), sc<int>(w->m_realSize->goal().y), w->m_workspace ? w->workspaceID() : WORKSPACE_INVALID, - (!w->m_workspace ? "" : w->m_workspace->m_name), sc<int>(w->m_isFloating), w->monitorID(), w->m_class, w->m_title, w->m_initialClass, w->m_initialTitle, w->getPID(), - sc<int>(w->m_isX11), sc<int>(w->m_pinned), sc<uint8_t>(w->m_fullscreenState.internal), sc<uint8_t>(w->m_fullscreenState.client), sc<int>(w->m_createdOverFullscreen), - getGroupedData(w, format), getTagsData(w, format), rc<uintptr_t>(w->m_swallowed.get()), getFocusHistoryID(w), sc<int>(g_pInputManager->isWindowInhibiting(w, false)), - w->xdgTag().value_or(""), w->xdgDescription().value_or(""), NContentType::toString(w->getContentType()), w->m_stableID); + rc<uintptr_t>(w.get()), w->m_title, sc<int>(w->m_isMapped), sc<int>(w->isHidden()), sc<int>(w->visible()), sc<int>(w->acceptsInput()), + sc<int>(w->m_realPosition->goal().x), sc<int>(w->m_realPosition->goal().y), sc<int>(w->m_realSize->goal().x), sc<int>(w->m_realSize->goal().y), + w->m_workspace ? w->workspaceID() : WORKSPACE_INVALID, (!w->m_workspace ? "" : w->m_workspace->m_name), sc<int>(w->m_isFloating), w->monitorID(), w->m_class, + w->m_title, w->m_initialClass, w->m_initialTitle, w->getPID(), sc<int>(w->m_isX11), sc<int>(w->m_pinned), sc<uint8_t>(w->m_fullscreenState.internal), + sc<uint8_t>(w->m_fullscreenState.client), sc<int>(w->m_createdOverFullscreen), getGroupedData(w, format), getTagsData(w, format), rc<uintptr_t>(w->m_swallowed.get()), + getFocusHistoryID(w), sc<int>(g_pInputManager->isWindowInhibiting(w, false)), w->xdgTag().value_or(""), w->xdgDescription().value_or(""), + NContentType::toString(w->getContentType()), w->m_stableID); } } 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) { diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index 37606d4f..96d80bf3 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -1755,7 +1755,7 @@ uint32_t CMonitor::isSolitaryBlocked(bool full) { } for (auto const& w : g_pCompositor->m_windows) { - if (w == PCANDIDATE || (!w->m_isMapped && !w->m_fadingOut) || w->isHidden()) + if (w == PCANDIDATE || (!w->m_isMapped && !w->m_fadingOut) || !w->visible()) continue; if (w->workspaceID() == PCANDIDATE->workspaceID() && w->m_isFloating && w->m_createdOverFullscreen && w->visibleOnMonitor(m_self.lock())) { diff --git a/src/layout/algorithm/tiled/monocle/MonocleAlgorithm.cpp b/src/layout/algorithm/tiled/monocle/MonocleAlgorithm.cpp index 36c59a4e..84b4f9e2 100644 --- a/src/layout/algorithm/tiled/monocle/MonocleAlgorithm.cpp +++ b/src/layout/algorithm/tiled/monocle/MonocleAlgorithm.cpp @@ -46,8 +46,10 @@ CMonocleAlgorithm::~CMonocleAlgorithm() { continue; const auto WINDOW = TARGET->window(); - if (WINDOW) - WINDOW->setHidden(false); + if (WINDOW) { + WINDOW->setInputBlocked(Desktop::View::INPUT_BLOCK_MONOCLE_INACTIVE, false); + *WINDOW->alpha(Desktop::View::WINDOW_ALPHA_LAYOUT) = 1.F; + } } m_focusCallback.reset(); @@ -81,8 +83,10 @@ void CMonocleAlgorithm::removeTarget(SP<ITarget> target) { // unhide window when removing from monocle layout const auto WINDOW = target->window(); - if (WINDOW) - WINDOW->setHidden(false); + if (WINDOW) { + WINDOW->setInputBlocked(Desktop::View::INPUT_BLOCK_MONOCLE_INACTIVE, false); + *WINDOW->alpha(Desktop::View::WINDOW_ALPHA_LAYOUT) = 1.F; + } const auto INDEX = std::distance(m_targetDatas.begin(), it); m_targetDatas.erase(it); @@ -142,7 +146,8 @@ void CMonocleAlgorithm::recalculate() { TARGET->setPositionGlobal(WORK_AREA); const bool SHOULD_BE_VISIBLE = ((int)i == m_currentVisibleIndex); - WINDOW->setHidden(!SHOULD_BE_VISIBLE); + WINDOW->setInputBlocked(Desktop::View::INPUT_BLOCK_MONOCLE_INACTIVE, !SHOULD_BE_VISIBLE); + *WINDOW->alpha(Desktop::View::WINDOW_ALPHA_LAYOUT) = SHOULD_BE_VISIBLE ? 1.F : 0.F; } } diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 08c50de1..6bb04cfa 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -1890,7 +1890,7 @@ void CHyprOpenGLImpl::preRender(PHLMONITOR pMonitor) { bool hasWindows = false; for (auto const& w : g_pCompositor->m_windows) { - if (w->m_workspace == pMonitor->m_activeWorkspace && !w->isHidden() && w->m_isMapped && (!w->m_isFloating || *PBLURXRAY)) { + if (w->m_workspace == pMonitor->m_activeWorkspace && w->visible() && w->m_isMapped && (!w->m_isFloating || *PBLURXRAY)) { // check if window is valid if (!windowShouldBeBlurred(w)) diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 81f7b723..48405c3d 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -529,6 +529,9 @@ void IHyprRenderer::renderWindow(PHLWINDOW pWindow, PHLMONITOR pMonitor, const T if (pWindow->isHidden() && !standalone) return; + if (!standalone && pWindow->effectiveAlpha() == 0.F && !pWindow->m_alpha.isBeingAnimated()) + return; + if (pWindow->m_fadingOut) { if (pMonitor == pWindow->m_monitor) // TODO: fix this renderSnapshot(pWindow); |
