diff options
author | vaxerski <[email protected]> | 2022-07-21 12:33:22 +0200 |
---|---|---|
committer | vaxerski <[email protected]> | 2022-07-21 12:33:22 +0200 |
commit | 75ce01b1a722b2ae39322f4a1413cb1c2d8ead16 (patch) | |
tree | c950e577098e605b54befc935897dc2e4687f198 | |
parent | 189cbe9f098816231673e9ebe1ac5fa5872f33e7 (diff) | |
download | Hyprland-75ce01b1a722b2ae39322f4a1413cb1c2d8ead16.tar.gz Hyprland-75ce01b1a722b2ae39322f4a1413cb1c2d8ead16.zip |
Make the thread manager into a wl event loop timer
-rw-r--r-- | src/managers/ThreadManager.cpp | 35 | ||||
-rw-r--r-- | src/managers/ThreadManager.hpp | 6 |
2 files changed, 17 insertions, 24 deletions
diff --git a/src/managers/ThreadManager.cpp b/src/managers/ThreadManager.cpp index fa3d0d4e..3ca4d550 100644 --- a/src/managers/ThreadManager.cpp +++ b/src/managers/ThreadManager.cpp @@ -1,34 +1,29 @@ #include "ThreadManager.hpp" #include "../debug/HyprCtl.hpp" +#include "../Compositor.hpp" -CThreadManager::CThreadManager() { - m_tMainThread = new std::thread([&]() { - // Call the handle method. - this->handle(); - }); +int slowUpdate = 0; - m_tMainThread->detach(); // detach and continue. -} +int handleTimer(void* data) { + const auto PTM = (CThreadManager*)data; -CThreadManager::~CThreadManager() { - // -} + g_pConfigManager->tick(); -int slowUpdate = 0; + wl_event_source_timer_update(PTM->m_esConfigTimer, 1000); -void CThreadManager::handle() { + return 0; +} +CThreadManager::CThreadManager() { g_pConfigManager->init(); HyprCtl::startHyprCtlSocket(); - while (3.1415f) { - slowUpdate++; - if (slowUpdate >= g_pConfigManager->getInt("general:max_fps")){ - g_pConfigManager->tick(); - slowUpdate = 0; - } + m_esConfigTimer = wl_event_loop_add_timer(g_pCompositor->m_sWLEventLoop, handleTimer, this); + + wl_event_source_timer_update(m_esConfigTimer, 1000); +} - std::this_thread::sleep_for(std::chrono::microseconds(1000000 / g_pConfigManager->getInt("general:max_fps"))); - } +CThreadManager::~CThreadManager() { + // }
\ No newline at end of file diff --git a/src/managers/ThreadManager.hpp b/src/managers/ThreadManager.hpp index 40ed88d6..0a716e0b 100644 --- a/src/managers/ThreadManager.hpp +++ b/src/managers/ThreadManager.hpp @@ -9,11 +9,9 @@ public: CThreadManager(); ~CThreadManager(); -private: + wl_event_source* m_esConfigTimer; - void handle(); - - std::thread* m_tMainThread; + private: }; inline std::unique_ptr<CThreadManager> g_pThreadManager;
\ No newline at end of file |