Fixed handling of requests to open media from non-primary windows.

This commit is contained in:
23rd 2022-06-08 10:04:35 +03:00
parent 16e61ae2b2
commit 873301e7df
2 changed files with 17 additions and 2 deletions

View file

@ -353,12 +353,16 @@ void Application::run() {
showOpenGLCrashNotification(); showOpenGLCrashNotification();
} }
_primaryWindow->openInMediaViewRequests( _openInMediaViewRequests.events(
) | rpl::start_with_next([=](Media::View::OpenRequest &&request) { ) | rpl::start_with_next([=](Media::View::OpenRequest &&request) {
if (_mediaView) { if (_mediaView) {
_mediaView->show(std::move(request)); _mediaView->show(std::move(request));
} }
}, _primaryWindow->lifetime()); }, _lifetime);
_primaryWindow->openInMediaViewRequests(
) | rpl::start_to_stream(
_openInMediaViewRequests,
_primaryWindow->lifetime());
{ {
const auto countries = std::make_shared<Countries::Manager>( const auto countries = std::make_shared<Countries::Manager>(
@ -448,6 +452,12 @@ void Application::enumerateWindows(Fn<void(
} }
} }
void Application::processSecondaryWindow(
not_null<Window::Controller*> window) {
window->openInMediaViewRequests(
) | rpl::start_to_stream(_openInMediaViewRequests, window->lifetime());
}
void Application::startTray() { void Application::startTray() {
using WindowRaw = not_null<Window::Controller*>; using WindowRaw = not_null<Window::Controller*>;
_tray->create(); _tray->create();
@ -1163,6 +1173,7 @@ Window::Controller *Application::ensureSeparateWindowForPeer(
peer->owner().history(peer), peer->owner().history(peer),
std::make_unique<Window::Controller>(peer, showAtMsgId) std::make_unique<Window::Controller>(peer, showAtMsgId)
).first->second.get(); ).first->second.get();
processSecondaryWindow(result);
result->widget()->show(); result->widget()->show();
result->finishFirstShow(); result->finishFirstShow();
return activate(result); return activate(result);

View file

@ -69,6 +69,7 @@ class Instance;
} // namespace Audio } // namespace Audio
namespace View { namespace View {
class OverlayWidget; class OverlayWidget;
struct OpenRequest;
} // namespace View } // namespace View
namespace Player { namespace Player {
class FloatController; class FloatController;
@ -326,6 +327,7 @@ private:
void enumerateWindows( void enumerateWindows(
Fn<void(not_null<Window::Controller*>)> callback) const; Fn<void(not_null<Window::Controller*>)> callback) const;
void processSecondaryWindow(not_null<Window::Controller*> window);
friend void QuitAttempt(); friend void QuitAttempt();
void quitDelayed(); void quitDelayed();
@ -406,6 +408,8 @@ private:
}; };
base::flat_map<not_null<QWidget*>, LeaveFilter> _leaveFilters; base::flat_map<not_null<QWidget*>, LeaveFilter> _leaveFilters;
rpl::event_stream<Media::View::OpenRequest> _openInMediaViewRequests;
rpl::lifetime _lifetime; rpl::lifetime _lifetime;
crl::time _lastNonIdleTime = 0; crl::time _lastNonIdleTime = 0;