Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/core/Seat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ void CSeatManager::registerSeat(SP<CCWlSeat> seat) {
if (!*HIDECURSOR)
g_pHyprlock->onHover(g_pHyprlock->m_vMouseLocation);

if (std::chrono::system_clock::now() > g_pHyprlock->m_tGraceEnds)
// Like onKey: grace input only counts once the session is locked.
if (!g_pHyprlock->isLocked() || std::chrono::system_clock::now() > g_pHyprlock->m_tGraceEnds)
return;

if (!g_pHyprlock->isFadingOutOrTerminating() && g_pHyprlock->m_vLastEnterCoords.distance({wl_fixed_to_double(surface_x), wl_fixed_to_double(surface_y)}) > 5) {
Expand Down
17 changes: 14 additions & 3 deletions src/core/hyprlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,13 +517,15 @@ void CHyprlock::run() {
}

void CHyprlock::fadeOutAndUnlock() {
m_fadeOutOrTerminate = true;

if (!m_sLockState.locked) {
Log::logger->log(Log::WARN, "Unlock called, but not locked yet. This can happen when dpms is off during the grace period.");
// Unlocking now would be a protocol error. Replay the request in onLockLocked.
Log::logger->log(Log::WARN, "Unlock called, but not locked yet. Deferring until the locked event. This can happen when dpms is off during the grace period.");
m_unlockPending = true;
return;
}

m_fadeOutOrTerminate = true;

g_pRenderer->startFadeOut(true);

renderAllOutputs();
Expand All @@ -541,6 +543,10 @@ bool CHyprlock::isLockAquired() {
return m_lockAquired;
}

bool CHyprlock::isLocked() {
return m_sLockState.locked;
}

void CHyprlock::clearPasswordBuffer() {
if (m_sPasswordState.passBuffer.empty())
return;
Expand Down Expand Up @@ -823,6 +829,11 @@ void CHyprlock::onLockLocked() {
Log::logger->log(Log::INFO, "onLockLocked called");

m_sLockState.locked = true;

if (m_unlockPending) {
m_unlockPending = false;
fadeOutAndUnlock();
}
}

void CHyprlock::onLockFinished() {
Expand Down
2 changes: 2 additions & 0 deletions src/core/hyprlock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class CHyprlock {
bool isFadingOutOrTerminating();
bool isTerminating();
bool isLockAquired();
bool isLocked();

ASP<CTimer> addTimer(const std::chrono::system_clock::duration& timeout, std::function<void(ASP<CTimer> self, void* data)> cb_, void* data, bool force = false);
void processTimers();
Expand Down Expand Up @@ -122,6 +123,7 @@ class CHyprlock {

private:
bool m_lockAquired = false;
bool m_unlockPending = false;
std::atomic_bool m_fadeOutOrTerminate = false;
std::atomic_bool m_bTerminate = false;

Expand Down