summaryrefslogtreecommitdiff
path: root/src/helpers/AsyncDialogBox.cpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2025-04-29 18:20:06 +0100
committerVaxry <vaxry@vaxry.net>2025-04-29 18:20:06 +0100
commit465e3d979d72da90ea4f715393a0d6d3098830b1 (patch)
tree6a079cb909199bd5e91520918a4eae9f6e005298 /src/helpers/AsyncDialogBox.cpp
parentb10a43dabc0d65a03a3a169ff292f0f18d9c6640 (diff)
window: make AsyncDialogBoxes not closeable
we don't want the user to accidentally close a popup for permissions or ANR. They can dismiss them by clicking an appropriate option.
Diffstat (limited to 'src/helpers/AsyncDialogBox.cpp')
-rw-r--r--src/helpers/AsyncDialogBox.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/helpers/AsyncDialogBox.cpp b/src/helpers/AsyncDialogBox.cpp
index 86eb9e1f..6cda0d44 100644
--- a/src/helpers/AsyncDialogBox.cpp
+++ b/src/helpers/AsyncDialogBox.cpp
@@ -6,6 +6,9 @@
using namespace Hyprutils::OS;
+static std::vector<pid_t> asyncDialogBoxes;
+
+//
SP<CAsyncDialogBox> CAsyncDialogBox::create(const std::string& title, const std::string& description, std::vector<std::string> buttons) {
if (!NFsUtils::executableExistsInPath("hyprland-dialog")) {
Debug::log(ERR, "CAsyncDialogBox: cannot create, no hyprland-dialog");
@@ -19,6 +22,10 @@ SP<CAsyncDialogBox> CAsyncDialogBox::create(const std::string& title, const std:
return dialog;
}
+bool CAsyncDialogBox::isAsyncDialogBox(pid_t pid) {
+ return std::ranges::contains(asyncDialogBoxes, pid);
+}
+
CAsyncDialogBox::CAsyncDialogBox(const std::string& title, const std::string& description, std::vector<std::string> buttons) :
m_title(title), m_description(description), m_buttons(buttons) {
;
@@ -60,6 +67,7 @@ void CAsyncDialogBox::onWrite(int fd, uint32_t mask) {
Debug::log(LOG, "CAsyncDialogBox: dialog {:x} hung up, closed.");
m_promiseResolver->resolve(m_stdout);
+ std::erase(asyncDialogBoxes, m_dialogPid);
wl_event_source_remove(m_readEventSource);
m_selfReference.reset();
@@ -103,6 +111,7 @@ SP<CPromise<std::string>> CAsyncDialogBox::open() {
}
m_dialogPid = proc.pid();
+ asyncDialogBoxes.emplace_back(m_dialogPid);
// close the write fd, only the dialog owns it now
close(outPipe[1]);