mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-24 02:05:59 +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 <sys/timerfd.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
#include <aquamarine/backend/Backend.hpp>
|
||||||
|
|
||||||
#define TIMESPEC_NSEC_PER_SEC 1000000000L
|
#define TIMESPEC_NSEC_PER_SEC 1000000000L
|
||||||
|
|
||||||
CEventLoopManager::CEventLoopManager(wl_display* display, wl_event_loop* wlEventLoop) {
|
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) {
|
static int aquamarineFDWrite(int fd, uint32_t mask, void* data) {
|
||||||
g_pCompositor->m_pAqBackend->dispatchEventsAsync();
|
auto POLLFD = (Aquamarine::SPollFD*)data;
|
||||||
|
POLLFD->onSignal();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEventLoopManager::enterLoop() {
|
void CEventLoopManager::enterLoop() {
|
||||||
m_sWayland.eventSource = wl_event_loop_add_fd(m_sWayland.loop, m_sTimers.timerfd, WL_EVENT_READABLE, timerWrite, nullptr);
|
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();
|
aqPollFDs = g_pCompositor->m_pAqBackend->getPollFDs();
|
||||||
for (auto& fd : aqFDs) {
|
for (auto& fd : aqPollFDs) {
|
||||||
m_sWayland.aqEventSources.emplace_back(wl_event_loop_add_fd(m_sWayland.loop, fd, WL_EVENT_READABLE, aquamarineFDWrite, nullptr));
|
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);
|
wl_display_run(m_sWayland.display);
|
||||||
|
|
|
@ -7,6 +7,10 @@
|
||||||
|
|
||||||
#include "EventLoopTimer.hpp"
|
#include "EventLoopTimer.hpp"
|
||||||
|
|
||||||
|
namespace Aquamarine {
|
||||||
|
struct SPollFD;
|
||||||
|
};
|
||||||
|
|
||||||
class CEventLoopManager {
|
class CEventLoopManager {
|
||||||
public:
|
public:
|
||||||
CEventLoopManager(wl_display* display, wl_event_loop* wlEventLoop);
|
CEventLoopManager(wl_display* display, wl_event_loop* wlEventLoop);
|
||||||
|
@ -45,6 +49,7 @@ class CEventLoopManager {
|
||||||
} m_sTimers;
|
} m_sTimers;
|
||||||
|
|
||||||
SIdleData m_sIdle;
|
SIdleData m_sIdle;
|
||||||
|
std::vector<SP<Aquamarine::SPollFD>> aqPollFDs;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::unique_ptr<CEventLoopManager> g_pEventLoopManager;
|
inline std::unique_ptr<CEventLoopManager> g_pEventLoopManager;
|
Loading…
Reference in a new issue