From f84216856a107e1ef5025a76bfd89f9d3121ae81 Mon Sep 17 00:00:00 2001 From: Nikolai Nechaev Date: Thu, 2 Jan 2025 17:49:58 +0300 Subject: [PATCH 1/2] `Manager::startAllHiding`: don't treat fading in notifications specially Previously, `Window::Notifications::Default::Manager` would not start hiding notifications that are fading in when other notifications should hide. This would lead to some notifications never hiding, e.g., when the cursor passes through the notification too quickly and there was not enough time for the notification to fade in completely. Also renamed `Widget::isShowing` -> `Widget::isFadingIn` for clarity. Fixes #28811. --- .../window/notifications_manager_default.cpp | 10 ++-------- .../SourceFiles/window/notifications_manager_default.h | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Telegram/SourceFiles/window/notifications_manager_default.cpp b/Telegram/SourceFiles/window/notifications_manager_default.cpp index 8ff3e2323deb63..5bf6f6099176d2 100644 --- a/Telegram/SourceFiles/window/notifications_manager_default.cpp +++ b/Telegram/SourceFiles/window/notifications_manager_default.cpp @@ -188,16 +188,10 @@ void Manager::checkLastInput() { void Manager::startAllHiding() { if (!hasReplyingNotification()) { - int notHidingCount = 0; for (const auto ¬ification : _notifications) { - if (notification->isShowing()) { - ++notHidingCount; - } else { - notification->startHiding(); - } + notification->startHiding(); } - notHidingCount += _queuedNotifications.size(); - if (_hideAll && notHidingCount < 2) { + if (_hideAll && _queuedNotifications.size() < 2) { _hideAll->startHiding(); } } diff --git a/Telegram/SourceFiles/window/notifications_manager_default.h b/Telegram/SourceFiles/window/notifications_manager_default.h index 5bd4344d8db4a5..7c81282355e7bd 100644 --- a/Telegram/SourceFiles/window/notifications_manager_default.h +++ b/Telegram/SourceFiles/window/notifications_manager_default.h @@ -143,7 +143,7 @@ class Widget : public Ui::RpWidget { int shift, Direction shiftDirection); - bool isShowing() const { + bool isFadingIn() const { return _a_opacity.animating() && !_hiding; } From a7b47e12976dc01a9295ef6b9804455733313676 Mon Sep 17 00:00:00 2001 From: Nikolai Nechaev Date: Wed, 1 Jan 2025 11:28:05 +0300 Subject: [PATCH 2/2] Notifications: stop fading in before starting to fade out When a notification is to start hiding (i.e., fade out), it is supposed to start fading out from the maximum opacity, even if it was not fully restored (which only happens if the cursor passed through the notification too quickly). Thus, call `.stop()` for the previous animation, if any, before `.start()`ing the next animation. --- Telegram/SourceFiles/window/notifications_manager_default.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Telegram/SourceFiles/window/notifications_manager_default.cpp b/Telegram/SourceFiles/window/notifications_manager_default.cpp index 5bf6f6099176d2..19d557e723663e 100644 --- a/Telegram/SourceFiles/window/notifications_manager_default.cpp +++ b/Telegram/SourceFiles/window/notifications_manager_default.cpp @@ -549,6 +549,10 @@ void Widget::hideStop() { void Widget::hideAnimated(float64 duration, const anim::transition &func) { _hiding = true; + // Stop the previous animation so as to make sure that the notification + // is fully restored before hiding it again. + // Relates to https://github.com/telegramdesktop/tdesktop/issues/28811. + _a_opacity.stop(); _a_opacity.start([this] { opacityAnimationCallback(); }, 1., 0., duration, func); }