internal: better mutex usage for ticks

This commit is contained in:
vaxerski 2023-05-08 19:07:28 +01:00
parent b4fdc0be52
commit 3596630a20
3 changed files with 5 additions and 2 deletions

View file

@ -26,13 +26,12 @@ void CHyprpaper::init() {
wl_registry_add_listener(registry, &Events::registryListener, nullptr);
while (wl_display_dispatch(m_sDisplay) != -1) {
std::lock_guard<std::mutex> lg(m_mtTickMutex);
tick(true);
}
}
void CHyprpaper::tick(bool force) {
std::lock_guard<std::mutex> lg(m_mtTickMutex);
bool reload = g_pIPCSocket->mainThreadParseRequest();
if (!reload && !force)

View file

@ -16,6 +16,7 @@ void Events::done(void *data, wl_output *wl_output) {
PMONITOR->readyForLS = true;
std::lock_guard<std::mutex> lg(g_pHyprpaper->m_mtTickMutex);
g_pHyprpaper->tick(true);
}
@ -151,6 +152,7 @@ void Events::handlePreferredScale(void *data, wp_fractional_scale_v1* fractional
if (pLS->fScale != SCALE) {
pLS->fScale = SCALE;
std::lock_guard<std::mutex> lg(g_pHyprpaper->m_mtTickMutex);
g_pHyprpaper->tick(true);
}
}

View file

@ -57,6 +57,8 @@ void CIPCSocket::initialize() {
break;
}
std::lock_guard<std::mutex> lg(g_pHyprpaper->m_mtTickMutex);
auto messageSize = read(ACCEPTEDCONNECTION, readBuffer, 1024);
readBuffer[messageSize == 1024 ? 1023 : messageSize] = '\0';