diff --git a/Telegram/SourceFiles/calls/calls_instance.cpp b/Telegram/SourceFiles/calls/calls_instance.cpp index daf06a64f5..475b2af982 100644 --- a/Telegram/SourceFiles/calls/calls_instance.cpp +++ b/Telegram/SourceFiles/calls/calls_instance.cpp @@ -236,9 +236,12 @@ void Instance::startOrJoinGroupCall( } void Instance::startOrJoinConferenceCall(StartConferenceInfo args) { - destroyCurrentCall( - args.migrating ? args.call.get() : nullptr, - args.migrating ? args.linkSlug : QString()); + const auto migrationInfo = (args.migrating && _currentCallPanel) + ? _currentCallPanel->migrationInfo() + : ConferencePanelMigration(); + if (!args.migrating) { + destroyCurrentCall(); + } const auto session = &args.call->peer()->session(); auto call = std::make_unique(_delegate.get(), args); @@ -249,7 +252,9 @@ void Instance::startOrJoinConferenceCall(StartConferenceInfo args) { destroyGroupCall(raw); }, raw->lifetime()); - _currentGroupCallPanel = std::make_unique(raw); + _currentGroupCallPanel = std::make_unique( + raw, + migrationInfo); _currentGroupCall = std::move(call); _currentGroupCallChanges.fire_copy(raw); if (!args.invite.empty()) { @@ -257,6 +262,10 @@ void Instance::startOrJoinConferenceCall(StartConferenceInfo args) { } else if (args.sharingLink && !args.linkSlug.isEmpty()) { _currentGroupCallPanel->migrationShowShareLink(); } + + if (args.migrating) { + destroyCurrentCall(args.call.get(), args.linkSlug); + } } void Instance::confirmLeaveCurrent( @@ -740,9 +749,11 @@ void Instance::destroyCurrentCall( } } if (const auto current = currentGroupCall()) { - current->hangup(); - if (const auto still = currentGroupCall()) { - destroyGroupCall(still); + if (!migrateCall || current->lookupReal() != migrateCall) { + current->hangup(); + if (const auto still = currentGroupCall()) { + destroyGroupCall(still); + } } } } diff --git a/Telegram/SourceFiles/calls/calls_panel.cpp b/Telegram/SourceFiles/calls/calls_panel.cpp index 02cb070432..3f2c0b31ac 100644 --- a/Telegram/SourceFiles/calls/calls_panel.cpp +++ b/Telegram/SourceFiles/calls/calls_panel.cpp @@ -233,6 +233,14 @@ bool Panel::isActive() const { return window()->isActiveWindow() && isVisible(); } +ConferencePanelMigration Panel::migrationInfo() const { + const auto handle = window()->windowHandle(); + return handle ? ConferencePanelMigration{ + .screen = handle->screen(), + .geometry = window()->geometry(), + } : ConferencePanelMigration(); +} + base::weak_ptr Panel::showToast( const QString &text, crl::time duration) { diff --git a/Telegram/SourceFiles/calls/calls_panel.h b/Telegram/SourceFiles/calls/calls_panel.h index b07e0ac7ed..13ba30c258 100644 --- a/Telegram/SourceFiles/calls/calls_panel.h +++ b/Telegram/SourceFiles/calls/calls_panel.h @@ -68,6 +68,7 @@ class Userpic; class SignalBars; class VideoBubble; struct DeviceSelection; +struct ConferencePanelMigration; class Panel final : public base::has_weak_ptr @@ -81,6 +82,8 @@ public: [[nodiscard]] bool isVisible() const; [[nodiscard]] bool isActive() const; + [[nodiscard]] ConferencePanelMigration migrationInfo() const; + base::weak_ptr showToast( const QString &text, crl::time duration = 0); diff --git a/Telegram/SourceFiles/calls/group/calls_group_common.h b/Telegram/SourceFiles/calls/group/calls_group_common.h index 6b8d5cedc2..267df9b324 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_common.h +++ b/Telegram/SourceFiles/calls/group/calls_group_common.h @@ -71,6 +71,11 @@ struct StartConferenceInfo { QString videoCaptureScreenId; }; +struct ConferencePanelMigration { + QScreen *screen = nullptr; + QRect geometry; +}; + } // namespace Calls namespace Calls::Group { diff --git a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp index 418d13943c..138c92d06e 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp @@ -191,6 +191,10 @@ struct Panel::ControlsBackgroundNarrow { }; Panel::Panel(not_null call) +: Panel(call, ConferencePanelMigration()) { +} + +Panel::Panel(not_null call, ConferencePanelMigration info) : _call(call) , _peer(call->peer()) , _layerBg(std::make_unique(widget())) @@ -253,7 +257,7 @@ Panel::Panel(not_null call) initWindow(); initWidget(); initControls(); - initLayout(); + initLayout(info); showAndActivate(); } @@ -1673,8 +1677,8 @@ void Panel::kickParticipantSure(not_null participantPeer) { } } -void Panel::initLayout() { - initGeometry(); +void Panel::initLayout(ConferencePanelMigration info) { + initGeometry(info); #ifndef Q_OS_MAC _controls->wrap.raise(); @@ -1704,22 +1708,32 @@ rpl::lifetime &Panel::lifetime() { return window()->lifetime(); } -void Panel::initGeometry() { - const auto center = Core::App().getPointForCallPanelCenter(); - const auto width = _call->rtmp() - ? st::groupCallWidthRtmp - : st::groupCallWidth; - const auto height = _call->rtmp() - ? st::groupCallHeightRtmp - : st::groupCallHeight; +void Panel::initGeometry(ConferencePanelMigration info) { const auto minWidth = _call->rtmp() ? st::groupCallWidthRtmpMin : st::groupCallWidth; const auto minHeight = _call->rtmp() ? st::groupCallHeightRtmpMin : st::groupCallHeight; - const auto rect = QRect(0, 0, width, height); - window()->setGeometry(rect.translated(center - rect.center())); + if (info.screen && !info.geometry.isEmpty()) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + window()->setScreen(info.screen); +#else // Qt >= 6.0.0 + window()->createWinId(); + window()->windowHandle()->setScreen(info.screen); +#endif // Qt < 6.0.0 + window()->setGeometry(info.geometry); + } else { + const auto center = Core::App().getPointForCallPanelCenter(); + const auto width = _call->rtmp() + ? st::groupCallWidthRtmp + : st::groupCallWidth; + const auto height = _call->rtmp() + ? st::groupCallHeightRtmp + : st::groupCallHeight; + const auto rect = QRect(0, 0, width, height); + window()->setGeometry(rect.translated(center - rect.center())); + } window()->setMinimumSize({ minWidth, minHeight }); window()->show(); } diff --git a/Telegram/SourceFiles/calls/group/calls_group_panel.h b/Telegram/SourceFiles/calls/group/calls_group_panel.h index 86108ca4b8..882049cb86 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_panel.h +++ b/Telegram/SourceFiles/calls/group/calls_group_panel.h @@ -75,6 +75,7 @@ struct CallBodyLayout; namespace Calls { struct InviteRequest; +struct ConferencePanelMigration; } // namespace Calls namespace Calls::Group { @@ -90,7 +91,8 @@ class Panel final : public base::has_weak_ptr , private Ui::DesktopCapture::ChooseSourceDelegate { public: - Panel(not_null call); + explicit Panel(not_null call); + Panel(not_null call, ConferencePanelMigration info); ~Panel(); [[nodiscard]] not_null widget() const; @@ -156,8 +158,8 @@ private: void initWidget(); void initControls(); void initShareAction(); - void initLayout(); - void initGeometry(); + void initLayout(ConferencePanelMigration info); + void initGeometry(ConferencePanelMigration info); void setupScheduledLabels(rpl::producer date); void setupMembers(); void setupVideo(not_null viewport);