summaryrefslogtreecommitdiff
path: root/src/helpers/AsyncDialogBox.hpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2025-04-27 00:03:32 +0100
committerVaxry <vaxry@vaxry.net>2025-04-27 13:28:06 +0100
commit0302bfdc2207f9b5482fb07aa6052e7f6cb237ca (patch)
treec2039f2d4f01327b23b39493bc03b90d195fa6d3 /src/helpers/AsyncDialogBox.hpp
parent4f868a1f3c1edfc1f5998f7d21e46e7c23aeb02f (diff)
async: add Promise and use it for AsyncDialogBox
Diffstat (limited to 'src/helpers/AsyncDialogBox.hpp')
-rw-r--r--src/helpers/AsyncDialogBox.hpp34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/helpers/AsyncDialogBox.hpp b/src/helpers/AsyncDialogBox.hpp
index d3cc242c..0cb95846 100644
--- a/src/helpers/AsyncDialogBox.hpp
+++ b/src/helpers/AsyncDialogBox.hpp
@@ -2,6 +2,7 @@
#include "../macros.hpp"
#include "./memory/Memory.hpp"
+#include "./defer/Promise.hpp"
#include <vector>
#include <functional>
@@ -15,29 +16,30 @@ class CAsyncDialogBox {
public:
static SP<CAsyncDialogBox> create(const std::string& title, const std::string& description, std::vector<std::string> buttons);
- CAsyncDialogBox(const CAsyncDialogBox&) = delete;
- CAsyncDialogBox(CAsyncDialogBox&&) = delete;
- CAsyncDialogBox& operator=(const CAsyncDialogBox&) = delete;
- CAsyncDialogBox& operator=(CAsyncDialogBox&&) = delete;
+ CAsyncDialogBox(const CAsyncDialogBox&) = delete;
+ CAsyncDialogBox(CAsyncDialogBox&&) = delete;
+ CAsyncDialogBox& operator=(const CAsyncDialogBox&) = delete;
+ CAsyncDialogBox& operator=(CAsyncDialogBox&&) = delete;
- void open(std::function<void(std::string)> onResolution);
- void kill();
- bool isRunning() const;
+ SP<CPromise<std::string>> open();
+ void kill();
+ bool isRunning() const;
- void onWrite(int fd, uint32_t mask);
+ void onWrite(int fd, uint32_t mask);
private:
CAsyncDialogBox(const std::string& title, const std::string& description, std::vector<std::string> buttons);
- pid_t m_dialogPid = 0;
- wl_event_source* m_readEventSource = nullptr;
- std::function<void(std::string)> m_onResolution;
- Hyprutils::OS::CFileDescriptor m_pipeReadFd;
- std::string m_stdout = "";
+ 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<std::string> m_buttons;
+ const std::string m_title;
+ const std::string m_description;
+ const std::vector<std::string> m_buttons;
+
+ SP<CPromiseResolver<std::string>> m_promiseResolver;
// WARNING: cyclic reference. This will be removed once the event source is removed to avoid dangling pointers
SP<CAsyncDialogBox> m_selfReference;