mirror of
https://github.com/hyprwm/hyprlock.git
synced 2026-05-19 19:28:08 +02:00
refactor(fingerprint): consolidate activity notification
This commit is contained in:
parent
9f1ff2af51
commit
7c2822bfdb
5 changed files with 29 additions and 22 deletions
|
|
@ -107,6 +107,15 @@ void CFingerprint::terminate() {
|
|||
releaseDevice();
|
||||
}
|
||||
|
||||
static void inactivityTimerCallback(ASP<CTimer> self, void* data) {
|
||||
if (!g_pAuth)
|
||||
return;
|
||||
auto fpImpl = g_pAuth->getImpl(AUTH_IMPL_FINGERPRINT);
|
||||
if (!fpImpl)
|
||||
return;
|
||||
((CFingerprint*)fpImpl.get())->onInactivityTimeout();
|
||||
}
|
||||
|
||||
void CFingerprint::setupInactivityTimer() {
|
||||
if (m_sInactiveTimeout <= 0 || m_sDBUSState.abort || m_sDBUSState.done)
|
||||
return;
|
||||
|
|
@ -116,11 +125,12 @@ void CFingerprint::setupInactivityTimer() {
|
|||
m_pInactivityTimer.reset();
|
||||
}
|
||||
|
||||
m_pInactivityTimer = g_pHyprlock->addTimer(std::chrono::milliseconds(m_sInactiveTimeout * 1000),
|
||||
[](ASP<CTimer> self, void* data) { ((CFingerprint*)data)->onInactivityTimeout(); }, this);
|
||||
m_pInactivityTimer = g_pHyprlock->addTimer(std::chrono::seconds(m_sInactiveTimeout), inactivityTimerCallback, nullptr);
|
||||
}
|
||||
|
||||
void CFingerprint::onActivity() {
|
||||
setupInactivityTimer();
|
||||
|
||||
if (!m_sDBUSState.verifying) {
|
||||
Debug::log(LOG, "fprint: activity detected, resuming verification");
|
||||
startVerify();
|
||||
|
|
@ -132,9 +142,7 @@ void CFingerprint::onInactivityTimeout() {
|
|||
return;
|
||||
|
||||
Debug::log(LOG, "fprint: inactivity timeout, pausing verification");
|
||||
|
||||
stopVerify();
|
||||
|
||||
releaseDevice();
|
||||
|
||||
m_sDBUSState.device.reset();
|
||||
|
|
@ -143,6 +151,7 @@ void CFingerprint::onInactivityTimeout() {
|
|||
m_sPrompt = "";
|
||||
g_pHyprlock->enqueueForceUpdateTimers();
|
||||
|
||||
m_pInactivityTimer->cancel();
|
||||
m_pInactivityTimer.reset();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ class CFingerprint : public IAuthImplementation {
|
|||
virtual void terminate();
|
||||
|
||||
void onActivity();
|
||||
void onInactivityTimeout();
|
||||
|
||||
std::shared_ptr<sdbus::IConnection> getConnection();
|
||||
|
||||
|
|
@ -56,6 +57,5 @@ class CFingerprint : public IAuthImplementation {
|
|||
bool stopVerify();
|
||||
bool releaseDevice();
|
||||
|
||||
void onInactivityTimeout();
|
||||
void setupInactivityTimer();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ void CSeatManager::registerSeat(SP<CCWlSeat> seat) {
|
|||
m_pPointer->setMotion([](CCWlPointer* r, uint32_t time, wl_fixed_t surface_x, wl_fixed_t surface_y) {
|
||||
g_pHyprlock->m_vMouseLocation = {wl_fixed_to_double(surface_x), wl_fixed_to_double(surface_y)};
|
||||
|
||||
g_pHyprlock->onMouseMove(g_pHyprlock->m_vMouseLocation);
|
||||
g_pHyprlock->notifyActivityToFingerprint();
|
||||
|
||||
if (!*HIDECURSOR)
|
||||
g_pHyprlock->onHover(g_pHyprlock->m_vMouseLocation);
|
||||
|
|
|
|||
|
|
@ -644,6 +644,8 @@ void CHyprlock::onKey(uint32_t key, bool down) {
|
|||
xkb_compose_state_reset(g_pSeatManager->m_pXKBComposeState);
|
||||
|
||||
renderAllOutputs();
|
||||
|
||||
notifyActivityToFingerprint();
|
||||
}
|
||||
|
||||
void CHyprlock::handleKeySym(xkb_keysym_t sym, bool composed) {
|
||||
|
|
@ -696,12 +698,7 @@ void CHyprlock::onClick(uint32_t button, bool down, const Vector2D& pos) {
|
|||
if (!m_focusedOutput->m_sessionLockSurface)
|
||||
return;
|
||||
|
||||
if (g_pAuth) {
|
||||
auto fpImpl = g_pAuth->getImpl(AUTH_IMPL_FINGERPRINT);
|
||||
if (fpImpl) {
|
||||
((CFingerprint*)fpImpl.get())->onActivity();
|
||||
}
|
||||
}
|
||||
notifyActivityToFingerprint();
|
||||
|
||||
const auto SCALEDPOS = pos * m_focusedOutput->m_sessionLockSurface->fractionalScale;
|
||||
const auto widgets = g_pRenderer->getOrCreateWidgetsFor(*m_focusedOutput->m_sessionLockSurface);
|
||||
|
|
@ -750,15 +747,6 @@ void CHyprlock::onHover(const Vector2D& pos) {
|
|||
m_focusedOutput->m_sessionLockSurface->render();
|
||||
}
|
||||
|
||||
void CHyprlock::onMouseMove(const Vector2D& pos) {
|
||||
if (g_pAuth) {
|
||||
auto fpImpl = g_pAuth->getImpl(AUTH_IMPL_FINGERPRINT);
|
||||
if (fpImpl) {
|
||||
((CFingerprint*)fpImpl.get())->onActivity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CHyprlock::acquireSessionLock() {
|
||||
Log::logger->log(Log::INFO, "Locking session");
|
||||
m_sLockState.lock = makeShared<CCExtSessionLockV1>(m_sWaylandState.sessionLock->sendLock());
|
||||
|
|
@ -931,6 +919,15 @@ void CHyprlock::enqueueForceUpdateTimers() {
|
|||
nullptr, false);
|
||||
}
|
||||
|
||||
void CHyprlock::notifyActivityToFingerprint() {
|
||||
if (!g_pAuth)
|
||||
return;
|
||||
auto fpImpl = g_pAuth->getImpl(AUTH_IMPL_FINGERPRINT);
|
||||
if (!fpImpl)
|
||||
return;
|
||||
((CFingerprint*)fpImpl.get())->onActivity();
|
||||
}
|
||||
|
||||
SP<CCZwlrScreencopyManagerV1> CHyprlock::getScreencopy() {
|
||||
return m_sWaylandState.screencopy;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ class CHyprlock {
|
|||
void onKey(uint32_t key, bool down);
|
||||
void onClick(uint32_t button, bool down, const Vector2D& pos);
|
||||
void onHover(const Vector2D& pos);
|
||||
void onMouseMove(const Vector2D& pos);
|
||||
void startKeyRepeat(xkb_keysym_t sym);
|
||||
void repeatKey(xkb_keysym_t sym);
|
||||
void handleKeySym(xkb_keysym_t sym, bool compose);
|
||||
|
|
@ -58,6 +57,8 @@ class CHyprlock {
|
|||
bool passwordCheckWaiting();
|
||||
std::optional<std::string> passwordLastFailReason();
|
||||
|
||||
void notifyActivityToFingerprint();
|
||||
|
||||
void renderOutput(const std::string& stringPort);
|
||||
void renderAllOutputs();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue