feat(slock): implement ext_session_lock_v1 backend

note: did not run lints or fully test yet
This commit is contained in:
outfoxxed 2024-02-28 04:37:52 -08:00
parent 70c5cf1e16
commit 1fa87b7c5a
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E
12 changed files with 525 additions and 1 deletions

View file

@ -0,0 +1,42 @@
#include "lock.hpp"
#include <private/qwaylandshellintegration_p.h>
#include <qtmetamacros.h>
#include "manager.hpp"
QSWaylandSessionLock::QSWaylandSessionLock(
QSWaylandSessionLockManager* manager,
::ext_session_lock_v1* lock
)
: manager(manager) {
this->init(lock); // if isInitialized is false that means we already unlocked.
}
QSWaylandSessionLock::~QSWaylandSessionLock() { this->unlock(); }
void QSWaylandSessionLock::unlock() {
if (this->isInitialized()) {
if (this->locked) this->unlock_and_destroy();
else this->destroy();
this->locked = false;
this->manager->active = nullptr;
emit this->unlocked();
}
}
bool QSWaylandSessionLock::active() const { return this->isInitialized(); }
bool QSWaylandSessionLock::hasCompositorLock() const { return this->locked; }
void QSWaylandSessionLock::ext_session_lock_v1_locked() {
this->locked = true;
emit this->compositorLocked();
}
void QSWaylandSessionLock::ext_session_lock_v1_finished() {
this->locked = false;
this->unlock();
}