From d9c8a378118d954932eb9906b07150ccd9a3a434 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sun, 18 May 2025 19:34:14 +0200 Subject: input: always allow focus to permission popups --- src/helpers/AsyncDialogBox.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/helpers/AsyncDialogBox.cpp') diff --git a/src/helpers/AsyncDialogBox.cpp b/src/helpers/AsyncDialogBox.cpp index 42dac469..697d61ba 100644 --- a/src/helpers/AsyncDialogBox.cpp +++ b/src/helpers/AsyncDialogBox.cpp @@ -7,7 +7,7 @@ using namespace Hyprutils::OS; -static std::vector asyncDialogBoxes; +static std::vector>> asyncDialogBoxes; // SP CAsyncDialogBox::create(const std::string& title, const std::string& description, std::vector buttons) { @@ -24,7 +24,18 @@ SP CAsyncDialogBox::create(const std::string& title, const std: } bool CAsyncDialogBox::isAsyncDialogBox(pid_t pid) { - return std::ranges::contains(asyncDialogBoxes, pid); + return std::ranges::find_if(asyncDialogBoxes, [pid](const auto& e) { return e.first == pid; }) != asyncDialogBoxes.end(); +} + +bool CAsyncDialogBox::isPriorityDialogBox(pid_t pid) { + for (const auto& [p, db] : asyncDialogBoxes) { + if (p != pid) + continue; + + return db && db->m_priority; + } + + return false; } CAsyncDialogBox::CAsyncDialogBox(const std::string& title, const std::string& description, std::vector buttons) : @@ -68,7 +79,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); + std::erase_if(asyncDialogBoxes, [this](const auto& e) { return e.first == m_dialogPid; }); wl_event_source_remove(m_readEventSource); m_selfReference.reset(); @@ -112,7 +123,7 @@ SP> CAsyncDialogBox::open() { } m_dialogPid = proc.pid(); - asyncDialogBoxes.emplace_back(m_dialogPid); + asyncDialogBoxes.emplace_back(std::make_pair<>(m_dialogPid, m_selfWeakReference)); // close the write fd, only the dialog owns it now close(outPipe[1]); -- cgit v1.2.3