From 920353370bba555010506a1c0b204675c60362fe Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Mon, 8 Dec 2025 15:04:40 +0000 Subject: desktop: cleanup, unify desktop elements as views (#12563) --- src/desktop/view/GlobalViewMethods.cpp | 82 ++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 src/desktop/view/GlobalViewMethods.cpp (limited to 'src/desktop/view/GlobalViewMethods.cpp') diff --git a/src/desktop/view/GlobalViewMethods.cpp b/src/desktop/view/GlobalViewMethods.cpp new file mode 100644 index 00000000..97dc9960 --- /dev/null +++ b/src/desktop/view/GlobalViewMethods.cpp @@ -0,0 +1,82 @@ +#include "GlobalViewMethods.hpp" +#include "../../Compositor.hpp" + +#include "LayerSurface.hpp" +#include "Window.hpp" +#include "Popup.hpp" +#include "Subsurface.hpp" +#include "SessionLock.hpp" + +#include "../../protocols/core/Compositor.hpp" +#include "../../protocols/core/Subcompositor.hpp" +#include "../../protocols/SessionLock.hpp" + +using namespace Desktop; +using namespace Desktop::View; + +std::vector> View::getViewsForWorkspace(PHLWORKSPACE ws) { + std::vector> views; + + for (const auto& w : g_pCompositor->m_windows) { + if (!w->visible() || w->m_workspace != ws) + continue; + + views.emplace_back(w); + + w->wlSurface()->resource()->breadthfirst( + [&views](SP s, const Vector2D& pos, void* data) { + auto surf = CWLSurface::fromResource(s); + if (!surf || !s->m_mapped) + return; + + views.emplace_back(surf->view()); + }, + nullptr); + + // xwl windows dont have this + if (w->m_popupHead) { + w->m_popupHead->breadthfirst( + [&views](SP s, void* data) { + auto surf = s->wlSurface(); + if (!surf || !s->visible()) + return; + + views.emplace_back(surf->view()); + }, + nullptr); + } + } + + for (const auto& l : g_pCompositor->m_layers) { + if (!l->visible() || l->m_monitor != ws->m_monitor) + continue; + + views.emplace_back(l); + + l->m_popupHead->breadthfirst( + [&views](SP p, void* data) { + auto surf = p->wlSurface(); + if (!surf || !p->visible()) + return; + + views.emplace_back(surf->view()); + }, + nullptr); + } + + for (const auto& v : g_pCompositor->m_otherViews) { + if (!v->visible() || !v->desktopComponent()) + continue; + + if (v->type() == VIEW_TYPE_LOCK_SCREEN) { + const auto LOCK = Desktop::View::CSessionLock::fromView(v); + if (LOCK->monitor() != ws->m_monitor) + continue; + + views.emplace_back(LOCK); + continue; + } + } + + return views; +} -- cgit v1.2.3