From d0b9fd0dc3796403fc5539f83f6192a41146edbe Mon Sep 17 00:00:00 2001 From: nerix Date: Sat, 19 Oct 2024 11:56:46 +0200 Subject: [PATCH] fix: animate emotes when overlay is open (#5659) --- CHANGELOG.md | 2 +- src/singletons/helper/GifTimer.cpp | 1 + src/singletons/helper/GifTimer.hpp | 12 ++++++++++++ src/widgets/OverlayWindow.cpp | 3 +++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc73acb3..52be2a89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ - Major: Add option to show pronouns in user card. (#5442, #5583) - Major: Release plugins alpha. (#5288) - Major: Improve high-DPI support on Windows. (#4868, #5391) -- Major: Added transparent overlay window (default keybind: CTRL + ALT + N). (#4746, #5643) +- Major: Added transparent overlay window (default keybind: CTRL + ALT + N). (#4746, #5643, #5659) - Minor: Removed the Ctrl+Shift+L hotkey for toggling the "live only" tab visibility state. (#5530) - Minor: Add support for Shared Chat messages. Shared chat messages can be filtered with the `flags.shared` filter variable, or with search using `is:shared`. Some messages like subscriptions are filtered on purpose to avoid confusion for the broadcaster. If you have both channels participating in Shared Chat open, only one of the message triggering your highlight will trigger. (#5606, #5625) - Minor: Moved tab visibility control to a submenu, without any toggle actions. (#5530) diff --git a/src/singletons/helper/GifTimer.cpp b/src/singletons/helper/GifTimer.cpp index 07e25538..42f1d326 100644 --- a/src/singletons/helper/GifTimer.cpp +++ b/src/singletons/helper/GifTimer.cpp @@ -26,6 +26,7 @@ void GIFTimer::initialize() QObject::connect(&this->timer, &QTimer::timeout, [this] { if (getSettings()->animationsWhenFocused && + this->openOverlayWindows_ == 0 && QApplication::activeWindow() == nullptr) { return; diff --git a/src/singletons/helper/GifTimer.hpp b/src/singletons/helper/GifTimer.hpp index ecb741be..a8004c8c 100644 --- a/src/singletons/helper/GifTimer.hpp +++ b/src/singletons/helper/GifTimer.hpp @@ -18,9 +18,21 @@ public: return this->position_; } + void registerOpenOverlayWindow() + { + this->openOverlayWindows_++; + } + + void unregisterOpenOverlayWindow() + { + assert(this->openOverlayWindows_ >= 1); + this->openOverlayWindows_--; + } + private: QTimer timer; long unsigned position_{}; + size_t openOverlayWindows_ = 0; }; } // namespace chatterino diff --git a/src/widgets/OverlayWindow.cpp b/src/widgets/OverlayWindow.cpp index 94811fa8..b6cff796 100644 --- a/src/widgets/OverlayWindow.cpp +++ b/src/widgets/OverlayWindow.cpp @@ -4,6 +4,7 @@ #include "common/FlagsEnum.hpp" #include "common/Literals.hpp" #include "controllers/hotkeys/HotkeyController.hpp" +#include "singletons/Emotes.hpp" #include "singletons/Settings.hpp" #include "singletons/WindowManager.hpp" #include "widgets/BaseWidget.hpp" @@ -166,6 +167,7 @@ OverlayWindow::OverlayWindow(IndirectChannel channel, this->addShortcuts(); this->triggerFirstActivation(); + getApp()->getEmotes()->getGIFTimer().registerOpenOverlayWindow(); } OverlayWindow::~OverlayWindow() @@ -173,6 +175,7 @@ OverlayWindow::~OverlayWindow() #ifdef Q_OS_WIN ::DestroyCursor(this->sizeAllCursor_); #endif + getApp()->getEmotes()->getGIFTimer().unregisterOpenOverlayWindow(); } void OverlayWindow::applyTheme()