mirror of
https://github.com/hyprwm/hyprlock.git
synced 2025-05-18 16:17:54 +01:00
core: don't rely on the locked event to create lock surfaces dynamically (#687)
This commit is contained in:
parent
82b63a6930
commit
c4b2175822
4 changed files with 31 additions and 21 deletions
|
@ -18,10 +18,10 @@ COutput::COutput(SP<CCWlOutput> output_, uint32_t name_) : name(name_), output(o
|
||||||
output->setScale([this](CCWlOutput* r, int32_t sc) { scale = sc; });
|
output->setScale([this](CCWlOutput* r, int32_t sc) { scale = sc; });
|
||||||
|
|
||||||
output->setDone([this](CCWlOutput* r) {
|
output->setDone([this](CCWlOutput* r) {
|
||||||
|
done = true;
|
||||||
Debug::log(LOG, "output {} done", name);
|
Debug::log(LOG, "output {} done", name);
|
||||||
if (g_pHyprlock->m_bLocked && !sessionLockSurface) {
|
if (g_pHyprlock->m_lockAquired && !sessionLockSurface) {
|
||||||
// if we are already locked, create a surface dynamically
|
Debug::log(LOG, "output {} creating a new lock surface", name);
|
||||||
Debug::log(LOG, "Creating a surface dynamically for output as we are already locked");
|
|
||||||
sessionLockSurface = std::make_unique<CSessionLockSurface>(this);
|
sessionLockSurface = std::make_unique<CSessionLockSurface>(this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,6 +12,7 @@ class COutput {
|
||||||
|
|
||||||
uint32_t name = 0;
|
uint32_t name = 0;
|
||||||
bool focused = false;
|
bool focused = false;
|
||||||
|
bool done = false;
|
||||||
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||||
Vector2D size;
|
Vector2D size;
|
||||||
int scale = 1;
|
int scale = 1;
|
||||||
|
|
|
@ -345,10 +345,8 @@ void CHyprlock::run() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
acquireSessionLock();
|
// Failed to lock the session
|
||||||
|
if (!acquireSessionLock()) {
|
||||||
// Recieved finished
|
|
||||||
if (m_bTerminate) {
|
|
||||||
m_sLoopState.timerEvent = true;
|
m_sLoopState.timerEvent = true;
|
||||||
m_sLoopState.timerCV.notify_all();
|
m_sLoopState.timerCV.notify_all();
|
||||||
g_pRenderer->asyncResourceGatherer->notify();
|
g_pRenderer->asyncResourceGatherer->notify();
|
||||||
|
@ -366,8 +364,6 @@ void CHyprlock::run() {
|
||||||
registerSignalAction(SIGSEGV, handleCriticalSignal);
|
registerSignalAction(SIGSEGV, handleCriticalSignal);
|
||||||
registerSignalAction(SIGABRT, handleCriticalSignal);
|
registerSignalAction(SIGABRT, handleCriticalSignal);
|
||||||
|
|
||||||
createSessionLockSurfaces();
|
|
||||||
|
|
||||||
pollfd pollfds[2];
|
pollfd pollfds[2];
|
||||||
pollfds[0] = {
|
pollfds[0] = {
|
||||||
.fd = wl_display_get_fd(m_sWaylandState.display),
|
.fd = wl_display_get_fd(m_sWaylandState.display),
|
||||||
|
@ -701,9 +697,13 @@ void CHyprlock::handleKeySym(xkb_keysym_t sym, bool composed) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprlock::acquireSessionLock() {
|
bool CHyprlock::acquireSessionLock() {
|
||||||
Debug::log(LOG, "Locking session");
|
Debug::log(LOG, "Locking session");
|
||||||
m_sLockState.lock = makeShared<CCExtSessionLockV1>(m_sWaylandState.sessionLock->sendLock());
|
m_sLockState.lock = makeShared<CCExtSessionLockV1>(m_sWaylandState.sessionLock->sendLock());
|
||||||
|
if (!m_sLockState.lock) {
|
||||||
|
Debug::log(ERR, "Failed to create a lock object!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
m_sLockState.lock->setLocked([this](CCExtSessionLockV1* r) { onLockLocked(); });
|
m_sLockState.lock->setLocked([this](CCExtSessionLockV1* r) { onLockLocked(); });
|
||||||
|
|
||||||
|
@ -711,6 +711,22 @@ void CHyprlock::acquireSessionLock() {
|
||||||
|
|
||||||
// roundtrip in case the compositor sends `finished` right away
|
// roundtrip in case the compositor sends `finished` right away
|
||||||
wl_display_roundtrip(m_sWaylandState.display);
|
wl_display_roundtrip(m_sWaylandState.display);
|
||||||
|
|
||||||
|
// recieved finished right away (probably already locked)
|
||||||
|
if (m_bTerminate)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_lockAquired = true;
|
||||||
|
|
||||||
|
// create a session lock surface for exiting outputs
|
||||||
|
for (auto& o : m_vOutputs) {
|
||||||
|
if (!o->done)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
o->sessionLockSurface = std::make_unique<CSessionLockSurface>(o.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprlock::releaseSessionLock() {
|
void CHyprlock::releaseSessionLock() {
|
||||||
|
@ -743,12 +759,6 @@ void CHyprlock::releaseSessionLock() {
|
||||||
wl_display_roundtrip(m_sWaylandState.display);
|
wl_display_roundtrip(m_sWaylandState.display);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprlock::createSessionLockSurfaces() {
|
|
||||||
for (auto& o : m_vOutputs) {
|
|
||||||
o->sessionLockSurface = std::make_unique<CSessionLockSurface>(o.get());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CHyprlock::onLockLocked() {
|
void CHyprlock::onLockLocked() {
|
||||||
Debug::log(LOG, "onLockLocked called");
|
Debug::log(LOG, "onLockLocked called");
|
||||||
|
|
||||||
|
|
|
@ -48,11 +48,9 @@ class CHyprlock {
|
||||||
void onLockLocked();
|
void onLockLocked();
|
||||||
void onLockFinished();
|
void onLockFinished();
|
||||||
|
|
||||||
void acquireSessionLock();
|
bool acquireSessionLock();
|
||||||
void releaseSessionLock();
|
void releaseSessionLock();
|
||||||
|
|
||||||
void createSessionLockSurfaces();
|
|
||||||
|
|
||||||
void attemptRestoreOnDeath();
|
void attemptRestoreOnDeath();
|
||||||
|
|
||||||
std::string spawnSync(const std::string& cmd);
|
std::string spawnSync(const std::string& cmd);
|
||||||
|
@ -88,6 +86,7 @@ class CHyprlock {
|
||||||
|
|
||||||
bool m_bTerminate = false;
|
bool m_bTerminate = false;
|
||||||
|
|
||||||
|
bool m_lockAquired = false;
|
||||||
bool m_bLocked = false;
|
bool m_bLocked = false;
|
||||||
|
|
||||||
bool m_bCapsLock = false;
|
bool m_bCapsLock = false;
|
||||||
|
|
Loading…
Reference in a new issue