diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 0d9c2f8c8..a0a8c9ac8 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -1130,7 +1130,7 @@ PHLMONITOR CCompositor::getRealMonitorFromOutput(SP out) { SP CCompositor::vectorToLayerPopupSurface(const Vector2D& pos, PHLMONITOR monitor, Vector2D* sCoords, PHLLS* ppLayerSurfaceFound) { for (auto const& lsl : monitor->m_layerSurfaceLayers | std::views::reverse) { for (auto const& ls : lsl | std::views::reverse) { - if (!ls->visible() || ls->m_fadingOut) + if (!ls->aliveAndVisible()) continue; auto SURFACEAT = ls->m_popupHead->at(pos, true); @@ -1150,7 +1150,7 @@ SP CCompositor::vectorToLayerSurface(const Vector2D& pos, st bool aboveLockscreen) { for (auto const& ls : *layerSurfaces | std::views::reverse) { - if (!ls->visible() || ls->m_fadingOut || (aboveLockscreen && ls->m_ruleApplicator->aboveLock().valueOrDefault() != 2)) + if (!ls->aliveAndVisible() || (aboveLockscreen && ls->m_ruleApplicator->aboveLock().valueOrDefault() != 2)) continue; auto [surf, local] = ls->m_layerSurface->m_surface->at(pos - ls->m_geometry.pos(), true); @@ -2347,7 +2347,7 @@ PHLLS CCompositor::getLayerSurfaceFromSurface(SP pSurface) { std::pair, bool> result = {pSurface, false}; for (auto const& ls : m_layers) { - if (!ls->visible() || ls->m_fadingOut) + if (!ls->aliveAndVisible()) continue; if (ls->m_layerSurface->m_surface == pSurface) diff --git a/src/desktop/view/GlobalViewMethods.cpp b/src/desktop/view/GlobalViewMethods.cpp index 97dc99606..83513e816 100644 --- a/src/desktop/view/GlobalViewMethods.cpp +++ b/src/desktop/view/GlobalViewMethods.cpp @@ -18,7 +18,7 @@ std::vector> View::getViewsForWorkspace(PHLWORKSPACE ws) { std::vector> views; for (const auto& w : g_pCompositor->m_windows) { - if (!w->visible() || w->m_workspace != ws) + if (!w->aliveAndVisible() || w->m_workspace != ws) continue; views.emplace_back(w); @@ -38,7 +38,7 @@ std::vector> View::getViewsForWorkspace(PHLWORKSPACE ws) { w->m_popupHead->breadthfirst( [&views](SP s, void* data) { auto surf = s->wlSurface(); - if (!surf || !s->visible()) + if (!surf || !s->aliveAndVisible()) return; views.emplace_back(surf->view()); @@ -48,7 +48,7 @@ std::vector> View::getViewsForWorkspace(PHLWORKSPACE ws) { } for (const auto& l : g_pCompositor->m_layers) { - if (!l->visible() || l->m_monitor != ws->m_monitor) + if (!l->aliveAndVisible() || l->m_monitor != ws->m_monitor) continue; views.emplace_back(l); @@ -56,7 +56,7 @@ std::vector> View::getViewsForWorkspace(PHLWORKSPACE ws) { l->m_popupHead->breadthfirst( [&views](SP p, void* data) { auto surf = p->wlSurface(); - if (!surf || !p->visible()) + if (!surf || !p->aliveAndVisible()) return; views.emplace_back(surf->view()); @@ -65,7 +65,7 @@ std::vector> View::getViewsForWorkspace(PHLWORKSPACE ws) { } for (const auto& v : g_pCompositor->m_otherViews) { - if (!v->visible() || !v->desktopComponent()) + if (!v->aliveAndVisible() || !v->desktopComponent()) continue; if (v->type() == VIEW_TYPE_LOCK_SCREEN) { diff --git a/src/desktop/view/LayerSurface.hpp b/src/desktop/view/LayerSurface.hpp index 3bca03d63..3660ee743 100644 --- a/src/desktop/view/LayerSurface.hpp +++ b/src/desktop/view/LayerSurface.hpp @@ -93,13 +93,13 @@ namespace Desktop::View { inline bool validMapped(PHLLS l) { if (!valid(l)) return false; - return l->visible(); + return l->aliveAndVisible(); } inline bool validMapped(PHLLSREF l) { if (!valid(l)) return false; - return l->visible(); + return l->aliveAndVisible(); } } diff --git a/src/desktop/view/View.cpp b/src/desktop/view/View.cpp index e7c6ce3ae..17a10c64b 100644 --- a/src/desktop/view/View.cpp +++ b/src/desktop/view/View.cpp @@ -1,4 +1,5 @@ #include "View.hpp" +#include "../../protocols/core/Compositor.hpp" using namespace Desktop; using namespace Desktop::View; @@ -14,3 +15,14 @@ IView::IView(SP pWlSurface) : m_wlSurface(pWlSurface) SP IView::resource() const { return m_wlSurface ? m_wlSurface->resource() : nullptr; } + +bool IView::aliveAndVisible() const { + auto res = resource(); + if (!res) + return false; + + if (!res->m_mapped) + return false; + + return visible(); +} diff --git a/src/desktop/view/View.hpp b/src/desktop/view/View.hpp index 0f412d2a1..4d777c36d 100644 --- a/src/desktop/view/View.hpp +++ b/src/desktop/view/View.hpp @@ -18,6 +18,7 @@ namespace Desktop::View { virtual SP wlSurface() const; virtual SP resource() const; + virtual bool aliveAndVisible() const; virtual eViewType type() const = 0; virtual bool visible() const = 0; virtual bool desktopComponent() const = 0; diff --git a/src/desktop/view/WLSurface.cpp b/src/desktop/view/WLSurface.cpp index 1bf90ae8d..8c3ce9db4 100644 --- a/src/desktop/view/WLSurface.cpp +++ b/src/desktop/view/WLSurface.cpp @@ -38,7 +38,7 @@ SP CWLSurface::resource() const { } bool CWLSurface::small() const { - if (!m_view || !m_view->visible() || m_view->type() != VIEW_TYPE_WINDOW || !exists()) + if (!m_view || !m_view->aliveAndVisible() || m_view->type() != VIEW_TYPE_WINDOW || !exists()) return false; if (!m_resource->m_current.texture) @@ -51,7 +51,7 @@ bool CWLSurface::small() const { } Vector2D CWLSurface::correctSmallVec() const { - if (!m_view || !m_view->visible() || m_view->type() != VIEW_TYPE_WINDOW || !exists() || !small() || !m_fillIgnoreSmall) + if (!m_view || !m_view->aliveAndVisible() || m_view->type() != VIEW_TYPE_WINDOW || !exists() || !small() || !m_fillIgnoreSmall) return {}; const auto SIZE = getViewporterCorrectedSize(); @@ -171,12 +171,6 @@ SP CWLSurface::constraint() const { return m_constraint.lock(); } -bool CWLSurface::visible() { - if (m_view) - return m_view->visible(); - return true; // non-desktop, we don't know much. -} - SP CWLSurface::fromResource(SP pSurface) { if (!pSurface) return nullptr; diff --git a/src/desktop/view/WLSurface.hpp b/src/desktop/view/WLSurface.hpp index 13c825941..944e863b7 100644 --- a/src/desktop/view/WLSurface.hpp +++ b/src/desktop/view/WLSurface.hpp @@ -38,7 +38,6 @@ namespace Desktop::View { Vector2D correctSmallVecBuf() const; // returns a corrective vector for small() surfaces, in BL coords Vector2D getViewporterCorrectedSize() const; CRegion computeDamage() const; // logical coordinates. May be wrong if the surface is unassigned - bool visible(); bool keyboardFocusable() const; SP view() const; diff --git a/src/desktop/view/Window.cpp b/src/desktop/view/Window.cpp index e27129a1f..f83235403 100644 --- a/src/desktop/view/Window.cpp +++ b/src/desktop/view/Window.cpp @@ -154,7 +154,7 @@ eViewType CWindow::type() const { } bool CWindow::visible() const { - return m_isMapped && !m_hidden && m_wlSurface && m_wlSurface->resource(); + return !m_hidden && ((m_isMapped && m_wlSurface && m_wlSurface->resource()) || (m_fadingOut && m_alpha->value() != 0.F)); } std::optional CWindow::logicalBox() const { diff --git a/src/managers/input/IdleInhibitor.cpp b/src/managers/input/IdleInhibitor.cpp index 0034a10fa..5750080c2 100644 --- a/src/managers/input/IdleInhibitor.cpp +++ b/src/managers/input/IdleInhibitor.cpp @@ -40,10 +40,10 @@ void CInputManager::recheckIdleInhibitorStatus() { auto WLSurface = Desktop::View::CWLSurface::fromResource(ii->inhibitor->m_surface.lock()); - if (!WLSurface) + if (!WLSurface || !WLSurface->view()) continue; - if (WLSurface->visible()) { + if (WLSurface->view()->aliveAndVisible()) { PROTO::idle->setInhibit(true); return; } @@ -85,10 +85,10 @@ bool CInputManager::isWindowInhibiting(const PHLWINDOW& w, bool onlyHl) { auto WLSurface = Desktop::View::CWLSurface::fromResource(surf); - if (!WLSurface) + if (!WLSurface || !WLSurface->view()) return; - if (WLSurface->visible()) + if (WLSurface->view()->aliveAndVisible()) *sc(data) = true; }, &isInhibiting); diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 38cd951d9..b75dd1e0f 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -684,8 +684,9 @@ void CHyprRenderer::renderWindow(PHLWINDOW pWindow, PHLMONITOR pMonitor, const T return; } - if (!popup->visible()) + if (!popup->aliveAndVisible()) return; + const auto pos = popup->coordsRelativeToParent(); const Vector2D oldPos = renderdata.pos; renderdata.pos += pos; @@ -802,7 +803,7 @@ void CHyprRenderer::renderLayer(PHLLS pLayer, PHLMONITOR pMonitor, const Time::s if (popups) { pLayer->m_popupHead->breadthfirst( [this, &renderdata](WP popup, void* data) { - if (!popup->visible()) + if (!popup->aliveAndVisible()) return; const auto SURF = popup->wlSurface()->resource(); @@ -1708,7 +1709,7 @@ void CHyprRenderer::renderWorkspace(PHLMONITOR pMonitor, PHLWORKSPACE pWorkspace void CHyprRenderer::sendFrameEventsToWorkspace(PHLMONITOR pMonitor, PHLWORKSPACE pWorkspace, const Time::steady_tp& now) { for (const auto& view : Desktop::View::getViewsForWorkspace(pWorkspace)) { - if (!view->visible()) + if (!view->aliveAndVisible()) continue; view->wlSurface()->resource()->frame(now); @@ -2505,7 +2506,7 @@ void CHyprRenderer::makeSnapshot(WP popup) { if (!PMONITOR || !PMONITOR->m_output || PMONITOR->m_pixelSize.x <= 0 || PMONITOR->m_pixelSize.y <= 0) return; - if (!popup->visible()) + if (!popup->aliveAndVisible()) return; Debug::log(LOG, "renderer: making a snapshot of {:x}", rc(popup.get()));