summaryrefslogtreecommitdiff
path: root/src/managers/EventManager.hpp
blob: c5755ae2966e172beb937c07bce910e6abd46e0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once
#include <deque>
#include <fstream>
#include <mutex>

#include "../defines.hpp"
#include "../helpers/MiscFunctions.hpp"

struct SHyprIPCEvent {
    std::string event;
    std::string data;
};

class CEventManager {
public:
    CEventManager();

    void postEvent(const SHyprIPCEvent event, bool force = false);

    void startThread();

    bool m_bIgnoreEvents = false;

    std::thread m_tThread;

private:

    void flushEvents();
    void ensureFDsValid();

    std::mutex eventQueueMutex;
    std::deque<SHyprIPCEvent> m_dQueuedEvents;

    std::deque<int> m_dAcceptedSocketFDs;
};

inline std::unique_ptr<CEventManager> g_pEventManager;