mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-25 08:53:48 -07:00
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
This commit is contained in:
@@ -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()));
|
||||
|
Reference in New Issue
Block a user