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();
}
_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<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() {
using WindowRaw = not_null<Window::Controller*>;
_tray->create();
@ -1163,6 +1173,7 @@ Window::Controller *Application::ensureSeparateWindowForPeer(
peer->owner().history(peer),
std::make_unique<Window::Controller>(peer, showAtMsgId)
).first->second.get();
processSecondaryWindow(result);
result->widget()->show();
result->finishFirstShow();
return activate(result);

View file

@ -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<void(not_null<Window::Controller*>)> callback) const;
void processSecondaryWindow(not_null<Window::Controller*> window);
friend void QuitAttempt();
void quitDelayed();
@ -406,6 +408,8 @@ private:
};
base::flat_map<not_null<QWidget*>, LeaveFilter> _leaveFilters;
rpl::event_stream<Media::View::OpenRequest> _openInMediaViewRequests;
rpl::lifetime _lifetime;
crl::time _lastNonIdleTime = 0;