@@ -640,11 +640,11 @@ void CWaylandPlatform::stopRepeatTimer() {
640640
641641SP<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
0 commit comments