diff options
| author | Vaxry <vaxry@vaxry.net> | 2025-05-18 19:34:14 +0200 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2025-05-18 19:34:20 +0200 |
| commit | d9c8a378118d954932eb9906b07150ccd9a3a434 (patch) | |
| tree | 018b2532fbde016d1791467ae77d3c1196819f63 /src/helpers/AsyncDialogBox.cpp | |
| parent | 158c0f2911894f5f97af7361f639f97f6d100c82 (diff) | |
input: always allow focus to permission popups
Diffstat (limited to 'src/helpers/AsyncDialogBox.cpp')
| -rw-r--r-- | src/helpers/AsyncDialogBox.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
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<pid_t> asyncDialogBoxes; +static std::vector<std::pair<pid_t, WP<CAsyncDialogBox>>> asyncDialogBoxes; // SP<CAsyncDialogBox> CAsyncDialogBox::create(const std::string& title, const std::string& description, std::vector<std::string> buttons) { @@ -24,7 +24,18 @@ SP<CAsyncDialogBox> 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<std::string> 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<CPromise<std::string>> 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]); |
