summaryrefslogtreecommitdiff
path: root/src/desktop
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/desktop
parent2ca7ad7efc1e20588af5c823ee46f23afad6cf91 (diff)
desktop/view: use aliveAndVisible for most things (#12631)
Diffstat (limited to 'src/desktop')
-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
7 files changed, 23 insertions, 17 deletions
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 {