* config: make fd use CFileDescriptor make use of the new hyprutils CFileDescriptor instead of manual FD handling. * hyprctl: make fd use CFileDescriptor make use of the new hyprutils CFileDescriptor instead of manual FD handling. * ikeyboard: make fd use CFileDescriptor make use of the new CFileDescriptor instead of manual FD handling, also in sendKeymap remove dead code, it already early returns if keyboard isnt valid, and dont try to close the FD that ikeyboard owns. * core: make SHMFile functions use CFileDescriptor make SHMFile misc functions use CFileDescriptor and its associated usage in dmabuf and keyboard. * core: make explicit sync use CFileDescriptor begin using CFileDescriptor in explicit sync and its timelines and eglsync usage in opengl, there is still a bit left with manual handling that requires future aquamarine change aswell. * eventmgr: make fd and sockets use CFileDescriptor make use of the hyprutils CFileDescriptor instead of manual FD and socket handling and closing. * eventloopmgr: make timerfd use CFileDescriptor make the timerfd use CFileDescriptor instead of manual fd handling * opengl: make gbm fd use CFileDescriptor make the gbm rendernode fd use CFileDescriptor instead of manual fd handling * core: make selection source/offer use CFileDescriptor make data selection source and offers use CFileDescriptor and its associated use in xwm and protocols * protocols: convert protocols fd to CFileDescriptor make most fd handling use CFileDescriptor in protocols * shm: make SHMPool use CfileDescriptor make SHMPool use CFileDescriptor instead of manual fd handling. * opengl: duplicate fd with CFileDescriptor duplicate fenceFD with CFileDescriptor duplicate instead. * xwayland: make sockets and fds use CFileDescriptor instead of manual opening/closing make sockets and fds use CFileDescriptor * keybindmgr: make sockets and fds use CFileDescriptor make sockets and fds use CFileDescriptor instead of manual handling.
73 lines
1.8 KiB
C++
73 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include <condition_variable>
|
|
#include <map>
|
|
#include <mutex>
|
|
#include <thread>
|
|
#include <wayland-server.h>
|
|
#include "helpers/signal/Signal.hpp"
|
|
#include <hyprutils/os/FileDescriptor.hpp>
|
|
|
|
#include "EventLoopTimer.hpp"
|
|
|
|
namespace Aquamarine {
|
|
struct SPollFD;
|
|
};
|
|
|
|
class CEventLoopManager {
|
|
public:
|
|
CEventLoopManager(wl_display* display, wl_event_loop* wlEventLoop);
|
|
~CEventLoopManager();
|
|
|
|
void enterLoop();
|
|
|
|
// Note: will remove the timer if the ptr is lost.
|
|
void addTimer(SP<CEventLoopTimer> timer);
|
|
void removeTimer(SP<CEventLoopTimer> timer);
|
|
|
|
void onTimerFire();
|
|
|
|
// recalculates timers
|
|
void nudgeTimers();
|
|
|
|
// schedules a function to run later, aka in a wayland idle event.
|
|
void doLater(const std::function<void()>& fn);
|
|
|
|
struct SIdleData {
|
|
wl_event_source* eventSource = nullptr;
|
|
std::vector<std::function<void()>> fns;
|
|
};
|
|
|
|
private:
|
|
// Manages the event sources after AQ pollFDs change.
|
|
void syncPollFDs();
|
|
|
|
struct SEventSourceData {
|
|
SP<Aquamarine::SPollFD> pollFD;
|
|
wl_event_source* eventSource = nullptr;
|
|
};
|
|
|
|
struct {
|
|
wl_event_loop* loop = nullptr;
|
|
wl_display* display = nullptr;
|
|
wl_event_source* eventSource = nullptr;
|
|
} m_sWayland;
|
|
|
|
struct {
|
|
std::vector<SP<CEventLoopTimer>> timers;
|
|
Hyprutils::OS::CFileDescriptor timerfd;
|
|
} m_sTimers;
|
|
|
|
SIdleData m_sIdle;
|
|
std::map<int, SEventSourceData> aqEventSources;
|
|
|
|
struct {
|
|
CHyprSignalListener pollFDsChanged;
|
|
} m_sListeners;
|
|
|
|
wl_event_source* m_configWatcherInotifySource = nullptr;
|
|
|
|
friend class CSyncTimeline;
|
|
};
|
|
|
|
inline UP<CEventLoopManager> g_pEventLoopManager;
|