mirror of
https://github.com/hyprwm/hyprlock.git
synced 2026-05-19 19:28:08 +02:00
Merge 617bcf7139 into 274154f92a
This commit is contained in:
commit
06bcaacb8b
6 changed files with 85 additions and 1 deletions
|
|
@ -40,6 +40,8 @@ CFingerprint::CFingerprint() {
|
|||
m_sFingerprintReady = *FINGERPRINTREADY;
|
||||
static const auto FINGERPRINTPRESENT = g_pConfigManager->getValue<Hyprlang::STRING>("auth:fingerprint:present_message");
|
||||
m_sFingerprintPresent = *FINGERPRINTPRESENT;
|
||||
static const auto INACTIVETIMEOUT = g_pConfigManager->getValue<Hyprlang::INT>("auth:fingerprint:inactive_timeout");
|
||||
m_sInactiveTimeout = *INACTIVETIMEOUT;
|
||||
}
|
||||
|
||||
CFingerprint::~CFingerprint() {
|
||||
|
|
@ -96,10 +98,63 @@ bool CFingerprint::checkWaiting() {
|
|||
}
|
||||
|
||||
void CFingerprint::terminate() {
|
||||
if (m_pInactivityTimer) {
|
||||
m_pInactivityTimer->cancel();
|
||||
m_pInactivityTimer.reset();
|
||||
}
|
||||
|
||||
if (!m_sDBUSState.abort)
|
||||
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;
|
||||
|
||||
if (m_pInactivityTimer) {
|
||||
m_pInactivityTimer->cancel();
|
||||
m_pInactivityTimer.reset();
|
||||
}
|
||||
|
||||
m_pInactivityTimer = g_pHyprlock->addTimer(std::chrono::seconds(m_sInactiveTimeout), inactivityTimerCallback, nullptr);
|
||||
}
|
||||
|
||||
void CFingerprint::onActivity() {
|
||||
setupInactivityTimer();
|
||||
|
||||
if (!m_sDBUSState.verifying) {
|
||||
Log::logger->log(Log::INFO, "fprint: activity detected, resuming verification");
|
||||
startVerify();
|
||||
}
|
||||
}
|
||||
|
||||
void CFingerprint::onInactivityTimeout() {
|
||||
if (m_sDBUSState.abort || m_sDBUSState.done || !m_sDBUSState.verifying)
|
||||
return;
|
||||
|
||||
Log::logger->log(Log::INFO, "fprint: inactivity timeout, pausing verification");
|
||||
stopVerify();
|
||||
releaseDevice();
|
||||
|
||||
m_sDBUSState.device.reset();
|
||||
|
||||
// Clear the prompt text to provide user feedback
|
||||
m_sPrompt = "";
|
||||
g_pHyprlock->enqueueForceUpdateTimers();
|
||||
|
||||
m_pInactivityTimer->cancel();
|
||||
m_pInactivityTimer.reset();
|
||||
}
|
||||
|
||||
std::shared_ptr<sdbus::IConnection> CFingerprint::getConnection() {
|
||||
return m_sDBUSState.connection;
|
||||
}
|
||||
|
|
@ -237,8 +292,11 @@ void CFingerprint::startVerify(bool isRetry) {
|
|||
if (isRetry) {
|
||||
m_sDBUSState.retries++;
|
||||
m_sPrompt = "Could not match fingerprint. Try again.";
|
||||
} else
|
||||
} else {
|
||||
m_sPrompt = m_sFingerprintReady;
|
||||
|
||||
setupInactivityTimer();
|
||||
}
|
||||
}
|
||||
g_pHyprlock->enqueueForceUpdateTimers();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@ class CFingerprint : public IAuthImplementation {
|
|||
virtual std::optional<std::string> getLastPrompt();
|
||||
virtual void terminate();
|
||||
|
||||
void onActivity();
|
||||
void onInactivityTimeout();
|
||||
|
||||
std::shared_ptr<sdbus::IConnection> getConnection();
|
||||
|
||||
private:
|
||||
|
|
@ -39,10 +42,13 @@ class CFingerprint : public IAuthImplementation {
|
|||
|
||||
std::string m_sFingerprintReady;
|
||||
std::string m_sFingerprintPresent;
|
||||
int m_sInactiveTimeout;
|
||||
|
||||
std::string m_sPrompt{""};
|
||||
std::string m_sFailureReason{""};
|
||||
|
||||
ASP<CTimer> m_pInactivityTimer;
|
||||
|
||||
void handleVerifyStatus(const std::string& result, const bool done);
|
||||
|
||||
bool createDeviceProxy();
|
||||
|
|
@ -50,4 +56,6 @@ class CFingerprint : public IAuthImplementation {
|
|||
void startVerify(bool isRetry = false);
|
||||
bool stopVerify();
|
||||
bool releaseDevice();
|
||||
|
||||
void setupInactivityTimer();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -254,6 +254,7 @@ void CConfigManager::init() {
|
|||
m_config.addConfigValue("auth:fingerprint:ready_message", Hyprlang::STRING{"(Scan fingerprint to unlock)"});
|
||||
m_config.addConfigValue("auth:fingerprint:present_message", Hyprlang::STRING{"Scanning fingerprint"});
|
||||
m_config.addConfigValue("auth:fingerprint:retry_delay", Hyprlang::INT{250});
|
||||
m_config.addConfigValue("auth:fingerprint:inactive_timeout", Hyprlang::INT{0});
|
||||
|
||||
m_config.addConfigValue("animations:enabled", Hyprlang::INT{1});
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ 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->notifyActivityToFingerprint();
|
||||
|
||||
if (!*HIDECURSOR)
|
||||
g_pHyprlock->onHover(g_pHyprlock->m_vMouseLocation);
|
||||
|
||||
|
|
|
|||
|
|
@ -655,6 +655,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) {
|
||||
|
|
@ -707,6 +709,8 @@ void CHyprlock::onClick(uint32_t button, bool down, const Vector2D& pos) {
|
|||
if (!m_focusedOutput->m_sessionLockSurface)
|
||||
return;
|
||||
|
||||
notifyActivityToFingerprint();
|
||||
|
||||
const auto SCALEDPOS = pos * m_focusedOutput->m_sessionLockSurface->fractionalScale;
|
||||
const auto widgets = g_pRenderer->getOrCreateWidgetsFor(*m_focusedOutput->m_sessionLockSurface);
|
||||
for (const auto& widget : widgets) {
|
||||
|
|
@ -927,6 +931,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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,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