summaryrefslogtreecommitdiff
path: root/src/managers/eventLoop/EventLoopManager.cpp
diff options
context:
space:
mode:
authorvaxerski <vaxry@vaxry.net>2025-01-19 15:39:19 +0100
committervaxerski <vaxry@vaxry.net>2025-01-19 16:11:12 +0100
commit8dd2cd41fb4c5a5eb6886cc190419b36084cabfa (patch)
tree713dfeb4f2bf75c2a04ed93166b5f9109dac9a84 /src/managers/eventLoop/EventLoopManager.cpp
parent0a0e56d99c3b5f900ec561b3fe9a3c8a64fe1217 (diff)
core: move to inotify for monitoring the config files
instead of manually polling every second which is not efficient, use inotify. an added bonus is that inotify is much much faster
Diffstat (limited to 'src/managers/eventLoop/EventLoopManager.cpp')
-rw-r--r--src/managers/eventLoop/EventLoopManager.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/managers/eventLoop/EventLoopManager.cpp b/src/managers/eventLoop/EventLoopManager.cpp
index db8b49b6..f98efc92 100644
--- a/src/managers/eventLoop/EventLoopManager.cpp
+++ b/src/managers/eventLoop/EventLoopManager.cpp
@@ -1,6 +1,7 @@
#include "EventLoopManager.hpp"
#include "../../debug/Log.hpp"
#include "../../Compositor.hpp"
+#include "../../config/ConfigWatcher.hpp"
#include <algorithm>
#include <limits>
@@ -27,6 +28,8 @@ CEventLoopManager::~CEventLoopManager() {
wl_event_source_remove(m_sWayland.eventSource);
if (m_sIdle.eventSource)
wl_event_source_remove(m_sIdle.eventSource);
+ if (m_configWatcherInotifySource)
+ wl_event_source_remove(m_configWatcherInotifySource);
if (m_sTimers.timerfd >= 0)
close(m_sTimers.timerfd);
}
@@ -42,9 +45,17 @@ static int aquamarineFDWrite(int fd, uint32_t mask, void* data) {
return 1;
}
+static int configWatcherWrite(int fd, uint32_t mask, void* data) {
+ g_pConfigWatcher->onInotifyEvent();
+ return 0;
+}
+
void CEventLoopManager::enterLoop() {
m_sWayland.eventSource = wl_event_loop_add_fd(m_sWayland.loop, m_sTimers.timerfd, WL_EVENT_READABLE, timerWrite, nullptr);
+ if (const auto FD = g_pConfigWatcher->getInotifyFD(); FD >= 0)
+ m_configWatcherInotifySource = wl_event_loop_add_fd(m_sWayland.loop, FD, WL_EVENT_READABLE, configWatcherWrite, nullptr);
+
aqPollFDs = g_pCompositor->m_pAqBackend->getPollFDs();
for (auto const& fd : aqPollFDs) {
m_sWayland.aqEventSources.emplace_back(wl_event_loop_add_fd(m_sWayland.loop, fd->fd, WL_EVENT_READABLE, aquamarineFDWrite, fd.get()));