mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-05-12 14:50:36 +01:00
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.
This commit is contained in:
parent
b10a43dabc
commit
465e3d979d
3 changed files with 16 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "../Compositor.hpp"
|
||||
#include "../helpers/WLClasses.hpp"
|
||||
#include "../helpers/AsyncDialogBox.hpp"
|
||||
#include "../managers/input/InputManager.hpp"
|
||||
#include "../managers/TokenManager.hpp"
|
||||
#include "../managers/SeatManager.hpp"
|
||||
|
@ -327,6 +328,11 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
|||
PWINDOW->applyDynamicRule(r);
|
||||
}
|
||||
|
||||
// make it uncloseable if it's a Hyprland dialog
|
||||
// TODO: make some closeable?
|
||||
if (CAsyncDialogBox::isAsyncDialogBox(PWINDOW->getPID()))
|
||||
PWINDOW->m_closeableSince = Time::steadyNow() + std::chrono::years(10 /* Should be enough, no? */);
|
||||
|
||||
// disallow tiled pinned
|
||||
if (PWINDOW->m_pinned && !PWINDOW->m_isFloating)
|
||||
PWINDOW->m_pinned = false;
|
||||
|
|
|
@ -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]);
|
||||
|
|
|
@ -15,6 +15,7 @@ struct wl_event_source;
|
|||
class CAsyncDialogBox {
|
||||
public:
|
||||
static SP<CAsyncDialogBox> create(const std::string& title, const std::string& description, std::vector<std::string> buttons);
|
||||
static bool isAsyncDialogBox(pid_t pid);
|
||||
|
||||
CAsyncDialogBox(const CAsyncDialogBox&) = delete;
|
||||
CAsyncDialogBox(CAsyncDialogBox&&) = delete;
|
||||
|
|
Loading…
Reference in a new issue