1
0
Fork 0
mirror of https://github.com/hyprwm/Hyprland synced 2025-04-12 09:51:50 +02:00

anr: add config for ping number before popup shows up ()

* anr: make pings configurable

makes the pings of the dialog popup configurable
This commit is contained in:
nyx 2025-03-31 12:06:17 -04:00 committed by GitHub
parent 79b526a041
commit 2309270752
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 16 additions and 6 deletions

View file

@ -1223,6 +1223,12 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
.type = CONFIG_OPTION_BOOL,
.data = SConfigOptionDescription::SBoolData{true},
},
SConfigOptionDescription{
.value = "misc:anr_missed_pings",
.description = "number of missed pings before showing the ANR dialog",
.type = CONFIG_OPTION_INT,
.data = SConfigOptionDescription::SRangeData{1, 1, 10},
},
/*
* binds:

View file

@ -460,6 +460,7 @@ CConfigManager::CConfigManager() {
registerConfigVar("misc:disable_hyprland_qtutils_check", Hyprlang::INT{0});
registerConfigVar("misc:lockdead_screen_delay", Hyprlang::INT{1000});
registerConfigVar("misc:enable_anr_dialog", Hyprlang::INT{1});
registerConfigVar("misc:anr_missed_pings", Hyprlang::INT{1});
registerConfigVar("group:insert_after_current", Hyprlang::INT{1});
registerConfigVar("group:focus_removed_window", Hyprlang::INT{1});

View file

@ -41,7 +41,8 @@ CANRManager::CANRManager() {
void CANRManager::onTick() {
std::erase_if(m_data, [](const auto& e) { return e->isDefunct(); });
static auto PENABLEANR = CConfigValue<Hyprlang::INT>("misc:enable_anr_dialog");
static auto PENABLEANR = CConfigValue<Hyprlang::INT>("misc:enable_anr_dialog");
static auto PANRTHRESHOLD = CConfigValue<Hyprlang::INT>("misc:anr_missed_pings");
if (!*PENABLEANR) {
m_timer->updateTimeout(TIMER_TIMEOUT * 10);
@ -66,7 +67,7 @@ void CANRManager::onTick() {
if (count == 0)
continue;
if (data->missedResponses > 0) {
if (data->missedResponses >= *PANRTHRESHOLD) {
if (!data->isThreadRunning() && !data->dialogThreadSaidWait) {
data->runDialog("Application Not Responding", firstWindow->m_szTitle, firstWindow->m_szClass, data->getPid());
@ -128,7 +129,8 @@ bool CANRManager::isNotResponding(PHLWINDOW pWindow) {
}
bool CANRManager::isNotResponding(SP<CANRManager::SANRData> data) {
return data->missedResponses > 1;
static auto PANRTHRESHOLD = CConfigValue<Hyprlang::INT>("misc:anr_missed_pings");
return data->missedResponses > *PANRTHRESHOLD;
}
SP<CANRManager::SANRData> CANRManager::dataFor(PHLWINDOW pWindow) {
@ -203,12 +205,13 @@ bool CANRManager::SANRData::isThreadRunning() {
return pthread_kill(dialogThread.native_handle(), 0) != ESRCH;
}
void CANRManager::SANRData::killDialog() const {
void CANRManager::SANRData::killDialog() {
if (!dialogProc)
return;
if (!dialogProc->pid()) {
Debug::log(ERR, "ANR: cannot kill dialogProc, as it doesn't have a pid. If you have hyprutils <= 0.6.0, you will crash soon. Otherwise, dialog failed to spawn??");
Debug::log(ERR, "ANR: cannot kill dialogProc, as it doesn't have a pid.");
dialogProc = nullptr;
return;
}

View file

@ -43,7 +43,7 @@ class CANRManager {
void runDialog(const std::string& title, const std::string& appName, const std::string appClass, pid_t dialogWmPID);
bool isThreadRunning();
void killDialog() const;
void killDialog();
bool isDefunct() const;
bool fitsWindow(PHLWINDOW pWindow) const;
pid_t getPid() const;