summaryrefslogtreecommitdiff
path: root/start/src/core/Instance.hpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2025-12-05 15:40:03 +0000
committerGitHub <noreply@github.com>2025-12-05 15:40:03 +0000
commit016eb7a23db54cb33ed722f682c7171027a91945 (patch)
tree47e9a200d1048a2a4d6b10fe7eae0bee4822c0a5 /start/src/core/Instance.hpp
parentec6756f961b5b6b12a53ec0387632e4495529f28 (diff)
start: init start-hyprland and safe mode (#12484)
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;