Skip to content

Commit 71be75a

Browse files
handle CCExtSessionLockV1 finished event
1 parent 2c7f7e9 commit 71be75a

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/core/platforms/WaylandPlatform.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -640,11 +640,11 @@ void CWaylandPlatform::stopRepeatTimer() {
640640

641641
SP<CCExtSessionLockV1> CWaylandPlatform::aquireSessionLock() {
642642
if (m_waylandState.sessionLockState.sessionLocked && m_waylandState.sessionLockState.sessionUnlocked) {
643-
g_logger->log(HT_LOG_ERROR, "We already unlocked. We shouldn't be calling aquireSessionLock?");
643+
g_logger->log(HT_LOG_ERROR, "We already unlocked. We shouldn't be calling aquireSessionLock.");
644644
return nullptr;
645645
}
646646

647-
if (!m_waylandState.sessionLockState.lock) {
647+
if (!m_waylandState.sessionLockState.lock && !m_waylandState.sessionLockState.denied) {
648648
m_waylandState.sessionLockState.lock = makeShared<CCExtSessionLockV1>(m_waylandState.sessionLock->sendLock());
649649
if (!m_waylandState.sessionLockState.lock) {
650650
g_logger->log(HT_LOG_ERROR, "Failed to create a session lock object!");
@@ -653,13 +653,21 @@ SP<CCExtSessionLockV1> CWaylandPlatform::aquireSessionLock() {
653653

654654
m_waylandState.sessionLockState.lock->setLocked([this](CCExtSessionLockV1* r) { m_waylandState.sessionLockState.sessionLocked = true; });
655655

656-
m_waylandState.sessionLockState.lock->setFinished([](CCExtSessionLockV1* r) { //FIXME: we need to make sure the client can exit after this event
656+
m_waylandState.sessionLockState.lock->setFinished([this](CCExtSessionLockV1* r) {
657+
g_logger->log(HT_LOG_ERROR, "We got denied by the compositor to be the exclusive lock screen client. Is there another lock screen active?");
658+
for (const auto& w : m_lockSurfaces) {
659+
if (w.expired())
660+
continue;
661+
w->m_events.closeRequest.emit();
662+
}
663+
664+
m_lockSurfaces.clear();
665+
m_waylandState.sessionLockState.lock.reset();
666+
m_waylandState.sessionLockState.denied = true;
657667
});
658668

659669
// roundtrip in case the compositor sends `finished` right away
660670
wl_display_roundtrip(m_waylandState.display);
661-
662-
// FIXME: we need to test if finished was sent right here too!
663671
}
664672

665673
return m_waylandState.sessionLockState.lock;
@@ -670,7 +678,7 @@ void CWaylandPlatform::unlockSessionLock() {
670678
return;
671679

672680
m_waylandState.sessionLockState.lock->sendUnlockAndDestroy();
673-
m_waylandState.sessionLockState.lock = nullptr;
681+
m_waylandState.sessionLockState.lock.reset();
674682
m_waylandState.sessionLockState.sessionUnlocked = true;
675683

676684
// roundtrip in order to make sure we have unlocked before sending closeRequest

src/core/platforms/WaylandPlatform.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ namespace Hyprtoolkit {
120120
SP<CCExtSessionLockV1> lock = nullptr;
121121
bool sessionLocked = false;
122122
bool sessionUnlocked = false;
123+
bool denied = false; // set on the finished event
123124
} sessionLockState;
124125
} m_waylandState;
125126

0 commit comments

Comments
 (0)