summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2025-12-11 16:29:26 +0000
committerGitHub <noreply@github.com>2025-12-11 16:29:26 +0000
commit5dd224805deb437f6fa83359ee66a4d0f52262d2 (patch)
tree9a5b2466a9cbbeaa03c8e3876fe103e18aad8794 /src
parent2ca7ad7efc1e20588af5c823ee46f23afad6cf91 (diff)
desktop/view: use aliveAndVisible for most things (#12631)
Diffstat (limited to 'src')
-rw-r--r--src/Compositor.cpp6
-rw-r--r--src/desktop/view/GlobalViewMethods.cpp10
-rw-r--r--src/desktop/view/LayerSurface.hpp4
-rw-r--r--src/desktop/view/View.cpp12
-rw-r--r--src/desktop/view/View.hpp1
-rw-r--r--src/desktop/view/WLSurface.cpp10
-rw-r--r--src/desktop/view/WLSurface.hpp1
-rw-r--r--src/desktop/view/Window.cpp2
-rw-r--r--src/managers/input/IdleInhibitor.cpp8
-rw-r--r--src/render/Renderer.cpp9
10 files changed, 35 insertions, 28 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index 0d9c2f8c..a0a8c9ac 100644
--- a/src/Compositor.cpp
+++ b/src/Compositor.cpp
@@ -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)
diff --git a/src/desktop/view/GlobalViewMethods.cpp b/src/desktop/view/GlobalViewMethods.cpp
index 97dc9960..83513e81 100644
--- a/src/desktop/view/GlobalViewMethods.cpp
+++ b/src/desktop/view/GlobalViewMethods.cpp
@@ -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) {
diff --git a/src/desktop/view/LayerSurface.hpp b/src/desktop/view/LayerSurface.hpp
index 3bca03d6..3660ee74 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 e7c6ce3a..17a10c64 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<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();
+}
diff --git a/src/desktop/view/View.hpp b/src/desktop/view/View.hpp
index 0f412d2a..4d777c36 100644
--- a/src/desktop/view/View.hpp
+++ b/src/desktop/view/View.hpp
@@ -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;
diff --git a/src/desktop/view/WLSurface.cpp b/src/desktop/view/WLSurface.cpp
index 1bf90ae8..8c3ce9db 100644
--- a/src/desktop/view/WLSurface.cpp
+++ b/src/desktop/view/WLSurface.cpp
@@ -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;
diff --git a/src/desktop/view/WLSurface.hpp b/src/desktop/view/WLSurface.hpp
index 13c82594..944e863b 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<IView> view() const;
diff --git a/src/desktop/view/Window.cpp b/src/desktop/view/Window.cpp
index e27129a1..f8323540 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<CBox> CWindow::logicalBox() const {
diff --git a/src/managers/input/IdleInhibitor.cpp b/src/managers/input/IdleInhibitor.cpp
index 0034a10f..5750080c 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<bool*>(data) = true;
},
&isInhibiting);
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index 38cd951d..b75dd1e0 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<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()));