summaryrefslogtreecommitdiff
path: root/src/desktop/view/SessionLock.cpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2025-12-08 15:04:40 +0000
committerGitHub <noreply@github.com>2025-12-08 15:04:40 +0000
commit920353370bba555010506a1c0b204675c60362fe (patch)
tree87ba1036ecad6294a9c86dfc828ed2a356c810bd /src/desktop/view/SessionLock.cpp
parent834f019bab5df85b912a7aab7054fc8306f7c52a (diff)
desktop: cleanup, unify desktop elements as views (#12563)
Diffstat (limited to 'src/desktop/view/SessionLock.cpp')
-rw-r--r--src/desktop/view/SessionLock.cpp74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/desktop/view/SessionLock.cpp b/src/desktop/view/SessionLock.cpp
new file mode 100644
index 00000000..a4a5b78b
--- /dev/null
+++ b/src/desktop/view/SessionLock.cpp
@@ -0,0 +1,74 @@
+#include "SessionLock.hpp"
+
+#include "../../protocols/SessionLock.hpp"
+#include "../../protocols/core/Compositor.hpp"
+#include "../../helpers/Monitor.hpp"
+
+#include "../../Compositor.hpp"
+
+using namespace Desktop;
+using namespace Desktop::View;
+
+SP<View::CSessionLock> View::CSessionLock::create(SP<CSessionLockSurface> resource) {
+ auto lock = SP<CSessionLock>(new CSessionLock());
+ lock->m_surface = resource;
+ lock->m_self = lock;
+
+ lock->init();
+
+ return lock;
+}
+
+View::CSessionLock::CSessionLock() : IView(CWLSurface::create()) {
+ ;
+}
+
+View::CSessionLock::~CSessionLock() {
+ m_wlSurface->unassign();
+}
+
+void View::CSessionLock::init() {
+ m_listeners.destroy = m_surface->m_events.destroy.listen([this] { std::erase_if(g_pCompositor->m_otherViews, [this](const auto& e) { return e == m_self; }); });
+
+ m_wlSurface->assign(m_surface->surface(), m_self.lock());
+}
+
+SP<View::CSessionLock> View::CSessionLock::fromView(SP<IView> v) {
+ if (!v || v->type() != VIEW_TYPE_LOCK_SCREEN)
+ return nullptr;
+ return dynamicPointerCast<View::CSessionLock>(v);
+}
+
+eViewType View::CSessionLock::type() const {
+ return VIEW_TYPE_LOCK_SCREEN;
+}
+
+bool View::CSessionLock::visible() const {
+ return m_wlSurface && m_wlSurface->resource() && m_wlSurface->resource()->m_mapped;
+}
+
+std::optional<CBox> View::CSessionLock::logicalBox() const {
+ return surfaceLogicalBox();
+}
+
+std::optional<CBox> View::CSessionLock::surfaceLogicalBox() const {
+ if (!visible())
+ return std::nullopt;
+
+ const auto MON = m_surface->monitor();
+
+ if (!MON)
+ return std::nullopt;
+
+ return MON->logicalBox();
+}
+
+bool View::CSessionLock::desktopComponent() const {
+ return true;
+}
+
+PHLMONITOR View::CSessionLock::monitor() const {
+ if (m_surface)
+ return m_surface->monitor();
+ return nullptr;
+}