desktop/view: use aliveAndVisible for most things (#12631)

This commit is contained in:
Vaxry 2025-12-11 16:29:26 +00:00 committed by GitHub
parent 2ca7ad7efc
commit 5dd224805d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 35 additions and 28 deletions

View file

@ -1130,7 +1130,7 @@ PHLMONITOR CCompositor::getRealMonitorFromOutput(SP<Aquamarine::IOutput> out) {
SP<CWLSurfaceResource> 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<CWLSurfaceResource> 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<CWLSurfaceResource> pSurface) {
std::pair<SP<CWLSurfaceResource>, 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)

View file

@ -18,7 +18,7 @@ std::vector<SP<IView>> View::getViewsForWorkspace(PHLWORKSPACE ws) {
std::vector<SP<IView>> 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<SP<IView>> View::getViewsForWorkspace(PHLWORKSPACE ws) {
w->m_popupHead->breadthfirst(
[&views](SP<CPopup> 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<SP<IView>> 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<SP<IView>> View::getViewsForWorkspace(PHLWORKSPACE ws) {
l->m_popupHead->breadthfirst(
[&views](SP<CPopup> 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<SP<IView>> 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) {

View file

@ -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();
}
}

View file

@ -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<Desktop::View::CWLSurface> pWlSurface) : m_wlSurface(pWlSurface)
SP<CWLSurfaceResource> 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();
}

View file

@ -18,6 +18,7 @@ namespace Desktop::View {
virtual SP<Desktop::View::CWLSurface> wlSurface() const;
virtual SP<CWLSurfaceResource> resource() const;
virtual bool aliveAndVisible() const;
virtual eViewType type() const = 0;
virtual bool visible() const = 0;
virtual bool desktopComponent() const = 0;

View file

@ -38,7 +38,7 @@ SP<CWLSurfaceResource> 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<CPointerConstraint> 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<Desktop::View::CWLSurface> CWLSurface::fromResource(SP<CWLSurfaceResource> pSurface) {
if (!pSurface)
return nullptr;

View file

@ -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<IView> view() const;

View file

@ -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<CBox> CWindow::logicalBox() const {

View file

@ -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<bool*>(data) = true;
},
&isInhibiting);

View file

@ -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<Desktop::View::CPopup> 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<Desktop::View::CPopup> 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<uintptr_t>(popup.get()));