diff options
| author | Vaxry <vaxry@vaxry.net> | 2024-07-05 23:05:03 +0200 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2024-07-05 23:05:09 +0200 |
| commit | cc98594c3aed0b542e03818371a4636f549f80e1 (patch) | |
| tree | 67740aecd3fb16ff435844d19537a7258930ddb7 /src/managers/eventLoop/EventLoopManager.cpp | |
| parent | 0502c3f62b1a562e7649ac72bd208b4a89d4f3f4 (diff) | |
pointer: update geometry after unplug events
fixes #6700
fixes #6740
Diffstat (limited to 'src/managers/eventLoop/EventLoopManager.cpp')
| -rw-r--r-- | src/managers/eventLoop/EventLoopManager.cpp | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/src/managers/eventLoop/EventLoopManager.cpp b/src/managers/eventLoop/EventLoopManager.cpp index 1193ffb8..0d1b0223 100644 --- a/src/managers/eventLoop/EventLoopManager.cpp +++ b/src/managers/eventLoop/EventLoopManager.cpp @@ -9,8 +9,10 @@ #define TIMESPEC_NSEC_PER_SEC 1000000000L -CEventLoopManager::CEventLoopManager() { - m_sTimers.timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC); +CEventLoopManager::CEventLoopManager(wl_display* display, wl_event_loop* wlEventLoop) { + m_sTimers.timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC); + m_sWayland.loop = wlEventLoop; + m_sWayland.display = display; } CEventLoopManager::~CEventLoopManager() { @@ -23,13 +25,10 @@ static int timerWrite(int fd, uint32_t mask, void* data) { return 1; } -void CEventLoopManager::enterLoop(wl_display* display, wl_event_loop* wlEventLoop) { - m_sWayland.loop = wlEventLoop; - m_sWayland.display = display; - - m_sWayland.eventSource = wl_event_loop_add_fd(wlEventLoop, m_sTimers.timerfd, WL_EVENT_READABLE, timerWrite, nullptr); +void CEventLoopManager::enterLoop() { + m_sWayland.eventSource = wl_event_loop_add_fd(m_sWayland.loop, m_sTimers.timerfd, WL_EVENT_READABLE, timerWrite, nullptr); - wl_display_run(display); + wl_display_run(m_sWayland.display); Debug::log(LOG, "Kicked off the event loop! :("); } @@ -86,4 +85,25 @@ void CEventLoopManager::nudgeTimers() { itimerspec ts = {.it_value = now}; timerfd_settime(m_sTimers.timerfd, TFD_TIMER_ABSTIME, &ts, nullptr); -}
\ No newline at end of file +} + +void CEventLoopManager::doLater(const std::function<void()>& fn) { + m_sIdle.fns.emplace_back(fn); + + if (m_sIdle.eventSource) + return; + + m_sIdle.eventSource = wl_event_loop_add_idle( + m_sWayland.loop, + [](void* data) { + auto IDLE = (CEventLoopManager::SIdleData*)data; + auto cpy = IDLE->fns; + IDLE->fns.clear(); + IDLE->eventSource = nullptr; + for (auto& c : cpy) { + if (c) + c(); + } + }, + &m_sIdle); +} |
