#pragma once #include "../macros.hpp" #include "./memory/Memory.hpp" #include "./defer/Promise.hpp" #include #include #include #include struct wl_event_source; class CAsyncDialogBox { public: static SP create(const std::string& title, const std::string& description, std::vector buttons); static bool isAsyncDialogBox(pid_t pid); static bool isPriorityDialogBox(pid_t pid); CAsyncDialogBox(const CAsyncDialogBox&) = delete; CAsyncDialogBox(CAsyncDialogBox&&) = delete; CAsyncDialogBox& operator=(const CAsyncDialogBox&) = delete; CAsyncDialogBox& operator=(CAsyncDialogBox&&) = delete; SP> open(); void kill(); bool isRunning() const; SP lockSelf(); // focus priority, only permission popups bool m_priority = false; void onWrite(int fd, uint32_t mask); private: CAsyncDialogBox(const std::string& title, const std::string& description, std::vector buttons); pid_t m_dialogPid = 0; wl_event_source* m_readEventSource = nullptr; Hyprutils::OS::CFileDescriptor m_pipeReadFd; std::string m_stdout = ""; const std::string m_title; const std::string m_description; const std::vector m_buttons; SP> m_promiseResolver; // WARNING: cyclic reference. This will be removed once the event source is removed to avoid dangling pointers SP m_selfReference; WP m_selfWeakReference; };