From 873301e7df8bd9799cd79930f42726fc3ff6f720 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 8 Jun 2022 10:04:35 +0300 Subject: [PATCH] Fixed handling of requests to open media from non-primary windows. --- Telegram/SourceFiles/core/application.cpp | 15 +++++++++++++-- Telegram/SourceFiles/core/application.h | 4 ++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index d96ac109b..439e0d0ce 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -353,12 +353,16 @@ void Application::run() { showOpenGLCrashNotification(); } - _primaryWindow->openInMediaViewRequests( + _openInMediaViewRequests.events( ) | rpl::start_with_next([=](Media::View::OpenRequest &&request) { if (_mediaView) { _mediaView->show(std::move(request)); } - }, _primaryWindow->lifetime()); + }, _lifetime); + _primaryWindow->openInMediaViewRequests( + ) | rpl::start_to_stream( + _openInMediaViewRequests, + _primaryWindow->lifetime()); { const auto countries = std::make_shared( @@ -448,6 +452,12 @@ void Application::enumerateWindows(Fn window) { + window->openInMediaViewRequests( + ) | rpl::start_to_stream(_openInMediaViewRequests, window->lifetime()); +} + void Application::startTray() { using WindowRaw = not_null; _tray->create(); @@ -1163,6 +1173,7 @@ Window::Controller *Application::ensureSeparateWindowForPeer( peer->owner().history(peer), std::make_unique(peer, showAtMsgId) ).first->second.get(); + processSecondaryWindow(result); result->widget()->show(); result->finishFirstShow(); return activate(result); diff --git a/Telegram/SourceFiles/core/application.h b/Telegram/SourceFiles/core/application.h index a376b4bb1..5853f7293 100644 --- a/Telegram/SourceFiles/core/application.h +++ b/Telegram/SourceFiles/core/application.h @@ -69,6 +69,7 @@ class Instance; } // namespace Audio namespace View { class OverlayWidget; +struct OpenRequest; } // namespace View namespace Player { class FloatController; @@ -326,6 +327,7 @@ private: void enumerateWindows( Fn)> callback) const; + void processSecondaryWindow(not_null window); friend void QuitAttempt(); void quitDelayed(); @@ -406,6 +408,8 @@ private: }; base::flat_map, LeaveFilter> _leaveFilters; + rpl::event_stream _openInMediaViewRequests; + rpl::lifetime _lifetime; crl::time _lastNonIdleTime = 0;