diff --git a/src/gui/PasswordWidget.cpp b/src/gui/PasswordWidget.cpp index 03751c8b1..2568ff67b 100644 --- a/src/gui/PasswordWidget.cpp +++ b/src/gui/PasswordWidget.cpp @@ -231,7 +231,7 @@ bool PasswordWidget::eventFilter(QObject* watched, QEvent* event) if (isVisible() && (type == QEvent::KeyPress || type == QEvent::KeyRelease || type == QEvent::FocusIn)) { checkCapslockState(); } - if (type == QEvent::FocusIn || type == QEvent::FocusOut) { + if (type == QEvent::FocusIn || type == QEvent::FocusOut || type == QEvent::Hide) { osUtils->setUserInputProtection(type == QEvent::FocusIn); } } diff --git a/src/gui/osutils/macutils/MacUtils.cpp b/src/gui/osutils/macutils/MacUtils.cpp index 893ec8fcc..b943561dc 100644 --- a/src/gui/osutils/macutils/MacUtils.cpp +++ b/src/gui/osutils/macutils/MacUtils.cpp @@ -152,11 +152,22 @@ bool MacUtils::isCapslockEnabled() void MacUtils::setUserInputProtection(bool enable) { + static bool secureInputEnabled = false; if (enable) { + /* + * MacOS keeps a single counter over all apps that needs to be zero to disable secure input. By never going + * higher than 1 internally this makes sure secure input doesn't stay active after calling this function + * multiple times. + */ + if (secureInputEnabled) { + DisableSecureEventInput(); + } EnableSecureEventInput(); } else { DisableSecureEventInput(); } + // Store our last known state + secureInputEnabled = enable; } /**