2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Optimize out most of LastUserInputTime() calls.

Fixes #16118.
This commit is contained in:
John Preston
2021-06-18 19:22:36 +04:00
parent 8897f9e46a
commit e1120d1cb5
12 changed files with 53 additions and 32 deletions

View File

@@ -158,8 +158,11 @@ float64 Manager::demoMasterOpacity() const {
void Manager::checkLastInput() {
auto replying = hasReplyingNotification();
auto waiting = false;
for_const (auto &notification, _notifications) {
if (!notification->checkLastInput(replying)) {
const auto lastInputTime = base::Platform::LastUserInputTimeSupported()
? std::make_optional(Core::App().lastNonIdleTime())
: std::nullopt;
for (const auto &notification : _notifications) {
if (!notification->checkLastInput(replying, lastInputTime)) {
waiting = true;
}
}
@@ -682,12 +685,14 @@ void Notification::prepareActionsCache() {
_buttonsCache = App::pixmapFromImageInPlace(std::move(actionsCacheImg));
}
bool Notification::checkLastInput(bool hasReplyingNotifications) {
bool Notification::checkLastInput(
bool hasReplyingNotifications,
std::optional<crl::time> lastInputTime) {
if (!_waitingForInput) return true;
const auto waitForUserInput = base::Platform::LastUserInputTimeSupported()
? (Core::App().lastNonIdleTime() <= _started)
: false;
const auto waitForUserInput = lastInputTime.has_value()
&& (*lastInputTime <= _started);
if (!waitForUserInput) {
_waitingForInput = false;
if (!hasReplyingNotifications) {