From 1f55dda5e2af30648d7d58dbb49dd5dfbef7bcf3 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 2 Nov 2022 21:41:32 +0000 Subject: [PATCH] stop polling in main thread --- src/Hyprpaper.cpp | 24 +++--------------------- src/ipc/Socket.cpp | 2 ++ 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/src/Hyprpaper.cpp b/src/Hyprpaper.cpp index 2511072..7fa3c9e 100644 --- a/src/Hyprpaper.cpp +++ b/src/Hyprpaper.cpp @@ -25,28 +25,10 @@ void CHyprpaper::init() { wl_registry *registry = wl_display_get_registry(m_sDisplay); wl_registry_add_listener(registry, &Events::registryListener, nullptr); - if (m_bIPCEnabled) { - std::thread([&]() { // we dispatch wl events cuz we have to - while (wl_display_dispatch(m_sDisplay) != -1) { - tick(true); - } - - m_bShouldExit = true; - }).detach(); - - while (true) { // we also tick every 1ms for socket and other shit's updates - tick(false); - - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - - if (m_bShouldExit) - break; - } - } else { - while (wl_display_dispatch(m_sDisplay) != -1) { - tick(true); - } + while (wl_display_dispatch(m_sDisplay) != -1) { + tick(true); } + } void CHyprpaper::tick(bool force) { diff --git a/src/ipc/Socket.cpp b/src/ipc/Socket.cpp index 57e3c3a..252e1d5 100644 --- a/src/ipc/Socket.cpp +++ b/src/ipc/Socket.cpp @@ -65,6 +65,8 @@ void CIPCSocket::initialize() { m_szRequest = request; m_bRequestReady = true; + g_pHyprpaper->tick(true); + while (1) { if (m_bReplyReady) break;