mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-03 21:54:05 +02:00
Keep window geometry on confcall migration.
This commit is contained in:
parent
fbbcbc8753
commit
c507382d19
6 changed files with 66 additions and 23 deletions
|
@ -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<GroupCall>(_delegate.get(), args);
|
||||
|
@ -249,7 +252,9 @@ void Instance::startOrJoinConferenceCall(StartConferenceInfo args) {
|
|||
destroyGroupCall(raw);
|
||||
}, raw->lifetime());
|
||||
|
||||
_currentGroupCallPanel = std::make_unique<Group::Panel>(raw);
|
||||
_currentGroupCallPanel = std::make_unique<Group::Panel>(
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Ui::Toast::Instance> Panel::showToast(
|
||||
const QString &text,
|
||||
crl::time duration) {
|
||||
|
|
|
@ -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<Ui::Toast::Instance> showToast(
|
||||
const QString &text,
|
||||
crl::time duration = 0);
|
||||
|
|
|
@ -71,6 +71,11 @@ struct StartConferenceInfo {
|
|||
QString videoCaptureScreenId;
|
||||
};
|
||||
|
||||
struct ConferencePanelMigration {
|
||||
QScreen *screen = nullptr;
|
||||
QRect geometry;
|
||||
};
|
||||
|
||||
} // namespace Calls
|
||||
|
||||
namespace Calls::Group {
|
||||
|
|
|
@ -191,6 +191,10 @@ struct Panel::ControlsBackgroundNarrow {
|
|||
};
|
||||
|
||||
Panel::Panel(not_null<GroupCall*> call)
|
||||
: Panel(call, ConferencePanelMigration()) {
|
||||
}
|
||||
|
||||
Panel::Panel(not_null<GroupCall*> call, ConferencePanelMigration info)
|
||||
: _call(call)
|
||||
, _peer(call->peer())
|
||||
, _layerBg(std::make_unique<Ui::LayerManager>(widget()))
|
||||
|
@ -253,7 +257,7 @@ Panel::Panel(not_null<GroupCall*> call)
|
|||
initWindow();
|
||||
initWidget();
|
||||
initControls();
|
||||
initLayout();
|
||||
initLayout(info);
|
||||
showAndActivate();
|
||||
}
|
||||
|
||||
|
@ -1673,8 +1677,8 @@ void Panel::kickParticipantSure(not_null<PeerData*> 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();
|
||||
}
|
||||
|
|
|
@ -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<GroupCall*> call);
|
||||
explicit Panel(not_null<GroupCall*> call);
|
||||
Panel(not_null<GroupCall*> call, ConferencePanelMigration info);
|
||||
~Panel();
|
||||
|
||||
[[nodiscard]] not_null<Ui::RpWidget*> 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<TimeId> date);
|
||||
void setupMembers();
|
||||
void setupVideo(not_null<Viewport*> viewport);
|
||||
|
|
Loading…
Add table
Reference in a new issue