core: check for sessionLockSurface before calling render

This is needed, because when a new monitor is added via `onGlobal` the
order of the events is not guaranteed. Meaning that render for a
particular monitor might get called before a `CSessionLockSurface` for
that monitor exists.
This commit is contained in:
Maximilian Seidler 2024-06-27 19:08:57 +02:00
parent 318c00d6d0
commit 8e91c4b0f9
2 changed files with 21 additions and 21 deletions

View file

@ -570,9 +570,7 @@ void CHyprlock::unlock() {
m_tFadeEnds = std::chrono::system_clock::now() + std::chrono::milliseconds(500);
m_bFadeStarted = true;
for (auto& o : m_vOutputs) {
o->sessionLockSurface->render();
}
renderAllOutputs();
}
// wl_seat
@ -758,9 +756,7 @@ static const ext_session_lock_v1_listener sessionLockListener = {
static void displayFailTextTimerCallback(std::shared_ptr<CTimer> self, void* data) {
g_pAuth->m_bDisplayFailText = false;
for (auto& o : g_pHyprlock->m_vOutputs) {
o->sessionLockSurface->render();
}
g_pHyprlock->renderAllOutputs();
}
void CHyprlock::onPasswordCheckTimer() {
@ -779,9 +775,7 @@ void CHyprlock::onPasswordCheckTimer() {
g_pAuth->start();
for (auto& o : m_vOutputs) {
o->sessionLockSurface->render();
}
renderAllOutputs();
}
}
@ -790,9 +784,8 @@ void CHyprlock::clearPasswordBuffer() {
return;
m_sPasswordState.passBuffer = "";
for (auto& o : m_vOutputs) {
o->sessionLockSurface->render();
}
renderAllOutputs();
}
void CHyprlock::renderOutput(const std::string& stringPort) {
@ -803,9 +796,21 @@ void CHyprlock::renderOutput(const std::string& stringPort) {
const auto PMONITOR = MON->get();
if (!PMONITOR->sessionLockSurface)
return;
PMONITOR->sessionLockSurface->render();
}
void CHyprlock::renderAllOutputs() {
for (auto& o : m_vOutputs) {
if (!o->sessionLockSurface)
continue;
o->sessionLockSurface->render();
}
}
void CHyprlock::startKeyRepeat(xkb_keysym_t sym) {
if (m_pKeyRepeatTimer) {
m_pKeyRepeatTimer->cancel();
@ -830,9 +835,7 @@ void CHyprlock::repeatKey(xkb_keysym_t sym) {
m_pKeyRepeatTimer = addTimer(
std::chrono::milliseconds(m_iKeebRepeatRate), [sym](std::shared_ptr<CTimer> self, void* data) { g_pHyprlock->repeatKey(sym); }, nullptr);
for (auto& o : m_vOutputs) {
o->sessionLockSurface->render();
}
renderAllOutputs();
}
void CHyprlock::onKey(uint32_t key, bool down) {
@ -863,9 +866,7 @@ void CHyprlock::onKey(uint32_t key, bool down) {
}
if (g_pAuth->checkWaiting()) {
for (auto& o : m_vOutputs) {
o->sessionLockSurface->render();
}
renderAllOutputs();
return;
}
@ -881,9 +882,7 @@ void CHyprlock::onKey(uint32_t key, bool down) {
startKeyRepeat(SYM);
}
for (auto& o : m_vOutputs) {
o->sessionLockSurface->render();
}
renderAllOutputs();
}
void CHyprlock::handleKeySym(xkb_keysym_t sym) {

View file

@ -64,6 +64,7 @@ class CHyprlock {
std::optional<std::string> passwordLastFailReason();
void renderOutput(const std::string& stringPort);
void renderAllOutputs();
size_t getPasswordBufferLen();
size_t getPasswordBufferDisplayLen();