2022-05-24 19:42:43 +02:00
|
|
|
#pragma once
|
|
|
|
#include <deque>
|
2024-05-10 13:32:50 +02:00
|
|
|
#include <vector>
|
2022-05-24 19:42:43 +02:00
|
|
|
|
|
|
|
#include "../defines.hpp"
|
2024-05-10 13:32:50 +02:00
|
|
|
#include "../helpers/memory/SharedPtr.hpp"
|
2022-05-24 19:42:43 +02:00
|
|
|
|
|
|
|
struct SHyprIPCEvent {
|
|
|
|
std::string event;
|
|
|
|
std::string data;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CEventManager {
|
2022-12-16 18:17:31 +01:00
|
|
|
public:
|
2022-05-24 19:42:43 +02:00
|
|
|
CEventManager();
|
2024-05-10 13:32:50 +02:00
|
|
|
~CEventManager();
|
2022-05-24 19:42:43 +02:00
|
|
|
|
2024-05-10 13:32:50 +02:00
|
|
|
void postEvent(const SHyprIPCEvent& event);
|
2022-05-24 19:42:43 +02:00
|
|
|
|
2024-05-10 13:32:50 +02:00
|
|
|
private:
|
|
|
|
std::string formatEvent(const SHyprIPCEvent& event) const;
|
2023-12-06 23:54:56 +01:00
|
|
|
|
2024-05-10 13:32:50 +02:00
|
|
|
static int onServerEvent(int fd, uint32_t mask, void* data);
|
|
|
|
static int onClientEvent(int fd, uint32_t mask, void* data);
|
2024-02-26 18:20:46 +01:00
|
|
|
|
2024-05-10 13:32:50 +02:00
|
|
|
int onServerEvent(int fd, uint32_t mask);
|
|
|
|
int onClientEvent(int fd, uint32_t mask);
|
2024-02-26 18:20:46 +01:00
|
|
|
|
2024-05-10 13:32:50 +02:00
|
|
|
struct SClient {
|
|
|
|
int fd = -1;
|
|
|
|
std::deque<SP<std::string>> events;
|
|
|
|
wl_event_source* eventSource = nullptr;
|
|
|
|
};
|
2022-05-24 19:42:43 +02:00
|
|
|
|
2024-05-10 13:32:50 +02:00
|
|
|
std::vector<SClient>::iterator findClientByFD(int fd);
|
|
|
|
std::vector<SClient>::iterator removeClientByFD(int fd);
|
2022-05-24 19:42:43 +02:00
|
|
|
|
2024-05-10 13:32:50 +02:00
|
|
|
private:
|
|
|
|
int m_iSocketFD = -1;
|
|
|
|
wl_event_source* m_pEventSource = nullptr;
|
2024-02-26 18:20:46 +01:00
|
|
|
|
2024-05-10 13:32:50 +02:00
|
|
|
std::vector<SClient> m_vClients;
|
2022-05-24 19:42:43 +02:00
|
|
|
};
|
|
|
|
|
2023-07-06 15:23:11 +02:00
|
|
|
inline std::unique_ptr<CEventManager> g_pEventManager;
|