From 99501d844dbf35728f8ed2b1a25e16526b7b5b1c Mon Sep 17 00:00:00 2001 From: Alexander Bushnev Date: Wed, 7 Apr 2021 21:46:35 +0200 Subject: [PATCH] Remember that media view was switched to PIP and open it as PIP again. Very useful, especially on large monitors. Since the permanent opening of the video in full screen interferes and hide other applications. This functionality allows remembering (in the current session) that the window has been switched to a PIP mode and will open a new video directly in the PIP mode. --- .../SourceFiles/media/view/media_view_overlay_widget.cpp | 5 +++++ Telegram/SourceFiles/media/view/media_view_overlay_widget.h | 1 + 2 files changed, 6 insertions(+) diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index cc3800b77..312d5568d 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -2213,6 +2213,9 @@ void OverlayWidget::showDocument( displayDocument(document, context, cloud, continueStreaming); preloadData(0); activateControls(); + if (_showAsPip && !videoIsGifOrUserpic()) { + switchToPip(); + } } void OverlayWidget::displayPhoto(not_null photo, HistoryItem *item) { @@ -2982,8 +2985,10 @@ void OverlayWidget::switchToPip() { const auto document = _document; const auto msgId = _msgid; const auto closeAndContinue = [=] { + _showAsPip = false; showDocument(document, document->owner().message(msgId), {}, true); }; + _showAsPip = true; _pip = std::make_unique( this, document, diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.h b/Telegram/SourceFiles/media/view/media_view_overlay_widget.h index a840d4c2d..b76a9f261 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.h +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.h @@ -443,6 +443,7 @@ private: std::unique_ptr _streamed; std::unique_ptr _pip; + bool _showAsPip = false; const style::icon *_docIcon = nullptr; style::color _docIconColor;