Allow PiP from another account.

This commit is contained in:
John Preston 2020-06-25 14:28:02 +04:00
parent 8fec04ba7a
commit c60b9cfa4d
2 changed files with 19 additions and 1 deletions

View file

@ -1069,7 +1069,6 @@ void OverlayWidget::clearSession() {
_from = nullptr; _from = nullptr;
_fromName = QString(); _fromName = QString();
assignMediaPointer(nullptr); assignMediaPointer(nullptr);
_pip = nullptr;
_fullScreenVideo = false; _fullScreenVideo = false;
_caption.clear(); _caption.clear();
_sharedMedia = nullptr; _sharedMedia = nullptr;
@ -1209,6 +1208,7 @@ void OverlayWidget::onToMessage() {
} }
if (const auto item = _session->data().message(_msgid)) { if (const auto item = _session->data().message(_msgid)) {
close(); close();
Core::App().domain().activate(&_session->account());
Ui::showPeerHistoryAtItem(item); Ui::showPeerHistoryAtItem(item);
} }
} }
@ -1449,6 +1449,7 @@ void OverlayWidget::onDelete() {
return false; return false;
}; };
Core::App().domain().activate(&_session->account());
const auto &active = _session->windows(); const auto &active = _session->windows();
if (active.empty()) { if (active.empty()) {
return; return;
@ -3845,6 +3846,11 @@ void OverlayWidget::mouseReleaseEvent(QMouseEvent *e) {
showSaveMsgFile(); showSaveMsgFile();
return; return;
} }
// There may be a mention / hashtag / bot command link.
// For now activate account for all activated links.
if (_session) {
Core::App().domain().activate(&_session->account());
}
ActivateClickHandler(this, activated, e->button()); ActivateClickHandler(this, activated, e->button());
return; return;
} }
@ -3852,6 +3858,7 @@ void OverlayWidget::mouseReleaseEvent(QMouseEvent *e) {
if (_over == OverName && _down == OverName) { if (_over == OverName && _down == OverName) {
if (_from) { if (_from) {
close(); close();
Core::App().domain().activate(&_from->account());
Ui::showPeerProfile(_from); Ui::showPeerProfile(_from);
} }
} else if (_over == OverDate && _down == OverDate) { } else if (_over == OverDate && _down == OverDate) {

View file

@ -17,6 +17,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_file_origin.h" #include "data/data_file_origin.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "data/data_media_rotation.h" #include "data/data_media_rotation.h"
#include "main/main_account.h"
#include "main/main_session.h"
#include "core/application.h" #include "core/application.h"
#include "base/platform/base_platform_info.h" #include "base/platform/base_platform_info.h"
#include "ui/platform/ui_platform_utility.h" #include "ui/platform/ui_platform_utility.h"
@ -875,6 +877,15 @@ Pip::Pip(
setupPanel(); setupPanel();
setupButtons(); setupButtons();
setupStreaming(); setupStreaming();
_data->session().account().sessionChanges(
) | rpl::start_with_next_done([=](Main::Session *session) {
if (!session) {
_destroy();
}
}, [=] {
_destroy();
}, _panel.lifetime());
} }
Pip::~Pip() = default; Pip::~Pip() = default;