summaryrefslogtreecommitdiff
path: root/src/managers/EventManager.hpp
blob: 348e3361d8c629538a11888131428bb12ab0ed86 (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
#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();

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

    std::deque<std::pair<int, wl_event_source*>> m_dAcceptedSocketFDs;
};

inline std::unique_ptr<CEventManager> g_pEventManager;