From 3fa0992148c344b32763c5bae13862ded3e3fcf8 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 20 Jul 2022 18:45:11 +0200 Subject: [PATCH] 1 --- src/Compositor.hpp | 2 ++ src/debug/HyprCtl.cpp | 4 ++++ src/helpers/WLListener.cpp | 3 +++ 3 files changed, 9 insertions(+) diff --git a/src/Compositor.hpp b/src/Compositor.hpp index 0500387c..982c6a48 100644 --- a/src/Compositor.hpp +++ b/src/Compositor.hpp @@ -72,6 +72,8 @@ public: std::string m_szInstanceSignature = ""; std::string m_szCurrentSplash = "error"; + std::mutex m_mtxEventLoopMutex; + std::vector> m_vMonitors; std::vector> m_vWindows; std::deque> m_dUnmanagedX11Windows; diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index 9832a22d..89b347e8 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -592,12 +592,16 @@ std::string getRequestFromThread(std::string rq) { static auto *const PNOVFR = &g_pConfigManager->getConfigValuePtr("misc:no_vfr")->intValue; + g_pCompositor->m_mtxEventLoopMutex.lock(); + // TODO: is this safe...? // this might be a race condition // tested with 2 instances of `watch -n 0.1 hyprctl splash` and seems to not crash so I'll take that as a yes if (!*PNOVFR) g_pCompositor->scheduleFrameForMonitor(g_pCompositor->m_vMonitors.front().get()); + g_pCompositor->m_mtxEventLoopMutex.unlock(); + while (HyprCtl::request != "" || HyprCtl::requestMade || HyprCtl::requestReady) { std::this_thread::sleep_for(std::chrono::milliseconds(5)); } diff --git a/src/helpers/WLListener.cpp b/src/helpers/WLListener.cpp index 117e16eb..6ce7436c 100644 --- a/src/helpers/WLListener.cpp +++ b/src/helpers/WLListener.cpp @@ -2,10 +2,13 @@ #include "MiscFunctions.hpp" #include #include "../debug/Log.hpp" +#include "../Compositor.hpp" void handleWrapped(wl_listener* listener, void* data) { CHyprWLListener* pListener = wl_container_of(listener, pListener, m_sListener); + std::lock_guard lg(g_pCompositor->m_mtxEventLoopMutex); + pListener->emit(data); }