mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-23 23:26:00 +01:00
new event api
This commit is contained in:
parent
65a16b84fc
commit
bd92c92ba1
2 changed files with 13 additions and 4 deletions
|
@ -8,6 +8,8 @@
|
|||
#include <sys/timerfd.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <aquamarine/backend/Backend.hpp>
|
||||
|
||||
#define TIMESPEC_NSEC_PER_SEC 1000000000L
|
||||
|
||||
CEventLoopManager::CEventLoopManager(wl_display* display, wl_event_loop* wlEventLoop) {
|
||||
|
@ -27,16 +29,18 @@ static int timerWrite(int fd, uint32_t mask, void* data) {
|
|||
}
|
||||
|
||||
static int aquamarineFDWrite(int fd, uint32_t mask, void* data) {
|
||||
g_pCompositor->m_pAqBackend->dispatchEventsAsync();
|
||||
auto POLLFD = (Aquamarine::SPollFD*)data;
|
||||
POLLFD->onSignal();
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CEventLoopManager::enterLoop() {
|
||||
m_sWayland.eventSource = wl_event_loop_add_fd(m_sWayland.loop, m_sTimers.timerfd, WL_EVENT_READABLE, timerWrite, nullptr);
|
||||
|
||||
auto aqFDs = g_pCompositor->m_pAqBackend->getPollFDs();
|
||||
for (auto& fd : aqFDs) {
|
||||
m_sWayland.aqEventSources.emplace_back(wl_event_loop_add_fd(m_sWayland.loop, fd, WL_EVENT_READABLE, aquamarineFDWrite, nullptr));
|
||||
aqPollFDs = g_pCompositor->m_pAqBackend->getPollFDs();
|
||||
for (auto& fd : aqPollFDs) {
|
||||
m_sWayland.aqEventSources.emplace_back(wl_event_loop_add_fd(m_sWayland.loop, fd->fd, WL_EVENT_READABLE, aquamarineFDWrite, fd.get()));
|
||||
fd->onSignal(); // dispatch outstanding
|
||||
}
|
||||
|
||||
wl_display_run(m_sWayland.display);
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
|
||||
#include "EventLoopTimer.hpp"
|
||||
|
||||
namespace Aquamarine {
|
||||
struct SPollFD;
|
||||
};
|
||||
|
||||
class CEventLoopManager {
|
||||
public:
|
||||
CEventLoopManager(wl_display* display, wl_event_loop* wlEventLoop);
|
||||
|
@ -45,6 +49,7 @@ class CEventLoopManager {
|
|||
} m_sTimers;
|
||||
|
||||
SIdleData m_sIdle;
|
||||
std::vector<SP<Aquamarine::SPollFD>> aqPollFDs;
|
||||
};
|
||||
|
||||
inline std::unique_ptr<CEventLoopManager> g_pEventLoopManager;
|
Loading…
Reference in a new issue