diff options
| author | davc0n <dconti.dev@gmail.com> | 2025-05-02 17:07:20 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-02 17:07:20 +0200 |
| commit | ce821294e21978cadf4c3facbeec421b245ea2c9 (patch) | |
| tree | aa90efb5251160cd1ed37fc9443f596f80f6dd96 /src/managers/SessionLockManager.cpp | |
| parent | 6f174a9e0892aab5c4c17a7da9be7f92bcdcebec (diff) | |
managers: refactor class member vars (#10242)
Diffstat (limited to 'src/managers/SessionLockManager.cpp')
| -rw-r--r-- | src/managers/SessionLockManager.cpp | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/src/managers/SessionLockManager.cpp b/src/managers/SessionLockManager.cpp index 83a238a6..bb01c944 100644 --- a/src/managers/SessionLockManager.cpp +++ b/src/managers/SessionLockManager.cpp @@ -42,7 +42,7 @@ SSessionLockSurface::SSessionLockSurface(SP<CSessionLockSurface> surface_) : sur } CSessionLockManager::CSessionLockManager() { - listeners.newLock = PROTO::sessionLock->events.newLock.registerListener([this](std::any data) { this->onNewSessionLock(std::any_cast<SP<CSessionLock>>(data)); }); + m_listeners.newLock = PROTO::sessionLock->events.newLock.registerListener([this](std::any data) { this->onNewSessionLock(std::any_cast<SP<CSessionLock>>(data)); }); } void CSessionLockManager::onNewSessionLock(SP<CSessionLock> pLock) { @@ -57,30 +57,30 @@ void CSessionLockManager::onNewSessionLock(SP<CSessionLock> pLock) { Debug::log(LOG, "Session got locked by {:x}", (uintptr_t)pLock.get()); - m_pSessionLock = makeUnique<SSessionLock>(); - m_pSessionLock->lock = pLock; - m_pSessionLock->mLockTimer.reset(); + m_sessionLock = makeUnique<SSessionLock>(); + m_sessionLock->lock = pLock; + m_sessionLock->mLockTimer.reset(); - m_pSessionLock->listeners.newSurface = pLock->events.newLockSurface.registerListener([this](std::any data) { + m_sessionLock->listeners.newSurface = pLock->events.newLockSurface.registerListener([this](std::any data) { auto SURFACE = std::any_cast<SP<CSessionLockSurface>>(data); const auto PMONITOR = SURFACE->monitor(); - const auto NEWSURFACE = m_pSessionLock->vSessionLockSurfaces.emplace_back(makeUnique<SSessionLockSurface>(SURFACE)).get(); + const auto NEWSURFACE = m_sessionLock->vSessionLockSurfaces.emplace_back(makeUnique<SSessionLockSurface>(SURFACE)).get(); NEWSURFACE->iMonitorID = PMONITOR->m_id; PROTO::fractional->sendScale(SURFACE->surface(), PMONITOR->m_scale); }); - m_pSessionLock->listeners.unlock = pLock->events.unlockAndDestroy.registerListener([this](std::any data) { - m_pSessionLock.reset(); + m_sessionLock->listeners.unlock = pLock->events.unlockAndDestroy.registerListener([this](std::any data) { + m_sessionLock.reset(); g_pInputManager->refocus(); for (auto const& m : g_pCompositor->m_monitors) g_pHyprRenderer->damageMonitor(m); }); - m_pSessionLock->listeners.destroy = pLock->events.destroyed.registerListener([this](std::any data) { - m_pSessionLock.reset(); + m_sessionLock->listeners.destroy = pLock->events.destroyed.registerListener([this](std::any data) { + m_sessionLock.reset(); g_pCompositor->focusSurface(nullptr); for (auto const& m : g_pCompositor->m_monitors) @@ -93,8 +93,8 @@ void CSessionLockManager::onNewSessionLock(SP<CSessionLock> pLock) { // Normally the locked event is sent after each output rendered a lock screen frame. // When there are no outputs, send it right away. if (g_pCompositor->m_unsafeState) { - m_pSessionLock->lock->sendLocked(); - m_pSessionLock->m_hasSentLocked = true; + m_sessionLock->lock->sendLocked(); + m_sessionLock->hasSentLocked = true; } } @@ -103,10 +103,10 @@ bool CSessionLockManager::isSessionLocked() { } WP<SSessionLockSurface> CSessionLockManager::getSessionLockSurfaceForMonitor(uint64_t id) { - if (!m_pSessionLock) + if (!m_sessionLock) return {}; - for (auto const& sls : m_pSessionLock->vSessionLockSurfaces) { + for (auto const& sls : m_sessionLock->vSessionLockSurfaces) { if (sls->iMonitorID == id) { if (sls->mapped) return sls; @@ -120,14 +120,14 @@ WP<SSessionLockSurface> CSessionLockManager::getSessionLockSurfaceForMonitor(uin // We don't want the red screen to flash. float CSessionLockManager::getRedScreenAlphaForMonitor(uint64_t id) { - if (!m_pSessionLock) + if (!m_sessionLock) return 1.F; - const auto& NOMAPPEDSURFACETIMER = m_pSessionLock->mMonitorsWithoutMappedSurfaceTimers.find(id); + const auto& NOMAPPEDSURFACETIMER = m_sessionLock->mMonitorsWithoutMappedSurfaceTimers.find(id); - if (NOMAPPEDSURFACETIMER == m_pSessionLock->mMonitorsWithoutMappedSurfaceTimers.end()) { - m_pSessionLock->mMonitorsWithoutMappedSurfaceTimers.emplace(id, CTimer()); - m_pSessionLock->mMonitorsWithoutMappedSurfaceTimers[id].reset(); + if (NOMAPPEDSURFACETIMER == m_sessionLock->mMonitorsWithoutMappedSurfaceTimers.end()) { + m_sessionLock->mMonitorsWithoutMappedSurfaceTimers.emplace(id, CTimer()); + m_sessionLock->mMonitorsWithoutMappedSurfaceTimers[id].reset(); return 0.f; } @@ -135,13 +135,13 @@ float CSessionLockManager::getRedScreenAlphaForMonitor(uint64_t id) { } void CSessionLockManager::onLockscreenRenderedOnMonitor(uint64_t id) { - if (!m_pSessionLock || m_pSessionLock->m_hasSentLocked) + if (!m_sessionLock || m_sessionLock->hasSentLocked) return; - m_pSessionLock->m_lockedMonitors.emplace(id); - const bool LOCKED = std::ranges::all_of(g_pCompositor->m_monitors, [this](auto m) { return m_pSessionLock->m_lockedMonitors.contains(m->m_id); }); - if (LOCKED && m_pSessionLock->lock->good()) { - m_pSessionLock->lock->sendLocked(); - m_pSessionLock->m_hasSentLocked = true; + m_sessionLock->lockedMonitors.emplace(id); + const bool LOCKED = std::ranges::all_of(g_pCompositor->m_monitors, [this](auto m) { return m_sessionLock->lockedMonitors.contains(m->m_id); }); + if (LOCKED && m_sessionLock->lock->good()) { + m_sessionLock->lock->sendLocked(); + m_sessionLock->hasSentLocked = true; } } @@ -149,10 +149,10 @@ bool CSessionLockManager::isSurfaceSessionLock(SP<CWLSurfaceResource> pSurface) // TODO: this has some edge cases when it's wrong (e.g. destroyed lock but not yet surfaces) // but can be easily fixed when I rewrite wlr_surface - if (!m_pSessionLock) + if (!m_sessionLock) return false; - for (auto const& sls : m_pSessionLock->vSessionLockSurfaces) { + for (auto const& sls : m_sessionLock->vSessionLockSurfaces) { if (sls->surface->surface() == pSurface) return true; } @@ -161,15 +161,15 @@ bool CSessionLockManager::isSurfaceSessionLock(SP<CWLSurfaceResource> pSurface) } void CSessionLockManager::removeSessionLockSurface(SSessionLockSurface* pSLS) { - if (!m_pSessionLock) + if (!m_sessionLock) return; - std::erase_if(m_pSessionLock->vSessionLockSurfaces, [&](const auto& other) { return pSLS == other.get(); }); + std::erase_if(m_sessionLock->vSessionLockSurfaces, [&](const auto& other) { return pSLS == other.get(); }); if (g_pCompositor->m_lastFocus) return; - for (auto const& sls : m_pSessionLock->vSessionLockSurfaces) { + for (auto const& sls : m_sessionLock->vSessionLockSurfaces) { if (!sls->mapped) continue; @@ -179,18 +179,18 @@ void CSessionLockManager::removeSessionLockSurface(SSessionLockSurface* pSLS) { } bool CSessionLockManager::isSessionLockPresent() { - return m_pSessionLock && !m_pSessionLock->vSessionLockSurfaces.empty(); + return m_sessionLock && !m_sessionLock->vSessionLockSurfaces.empty(); } bool CSessionLockManager::anySessionLockSurfacesPresent() { - return m_pSessionLock && std::ranges::any_of(m_pSessionLock->vSessionLockSurfaces, [](const auto& surf) { return surf->mapped; }); + return m_sessionLock && std::ranges::any_of(m_sessionLock->vSessionLockSurfaces, [](const auto& surf) { return surf->mapped; }); } bool CSessionLockManager::shallConsiderLockMissing() { - if (!m_pSessionLock) + if (!m_sessionLock) return false; static auto LOCKDEAD_SCREEN_DELAY = CConfigValue<Hyprlang::INT>("misc:lockdead_screen_delay"); - return m_pSessionLock->mLockTimer.getMillis() > *LOCKDEAD_SCREEN_DELAY; + return m_sessionLock->mLockTimer.getMillis() > *LOCKDEAD_SCREEN_DELAY; } |
