summaryrefslogtreecommitdiff
path: root/start/src/core/Instance.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'start/src/core/Instance.hpp')
-rw-r--r--start/src/core/Instance.hpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/start/src/core/Instance.hpp b/start/src/core/Instance.hpp
new file mode 100644
index 00000000..2c72dc12
--- /dev/null
+++ b/start/src/core/Instance.hpp
@@ -0,0 +1,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;