blob: 2c72dc12d5ec215d1cd6a8e3be8dde4bcbe6e30b (
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 <hyprutils/os/FileDescriptor.hpp>
#include <thread>
#include "../helpers/Memory.hpp"
class CHyprlandInstance {
public:
CHyprlandInstance() = default;
~CHyprlandInstance() = default;
CHyprlandInstance(const CHyprlandInstance&) = delete;
CHyprlandInstance(CHyprlandInstance&) = delete;
CHyprlandInstance(CHyprlandInstance&&) = delete;
bool run(bool safeMode = false); // if returns false, restart.
void forceQuit();
private:
void runHyprlandThread(bool safeMode);
void clearFd(const Hyprutils::OS::CFileDescriptor& fd);
void dispatchHyprlandEvent();
int m_hlPid = -1;
Hyprutils::OS::CFileDescriptor m_fromHlPid, m_toHlPid;
Hyprutils::OS::CFileDescriptor m_wakeupRead, m_wakeupWrite;
bool m_hyprlandInitialized = false;
bool m_hyprlandExiting = false;
std::thread m_hlThread;
};
inline UP<CHyprlandInstance> g_instance;
|