mirror of
https://github.com/hyprwm/hyprpaper.git
synced 2024-12-22 12:19:49 +01:00
internal: better mutex usage for ticks
This commit is contained in:
parent
b4fdc0be52
commit
3596630a20
3 changed files with 5 additions and 2 deletions
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
Loading…
Reference in a new issue