From 586744c112080a13dcbc0427babc6d2879ddd72b Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Fri, 29 May 2020 23:36:04 +0400 Subject: [PATCH] Apply sway fixes to the PiP and export windows too --- .../SourceFiles/media/view/media_view_pip.cpp | 16 +++++++++++++--- .../SourceFiles/ui/widgets/separate_panel.cpp | 18 +++++++++++++----- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/Telegram/SourceFiles/media/view/media_view_pip.cpp b/Telegram/SourceFiles/media/view/media_view_pip.cpp index fb8dd25aae..1475f1000f 100644 --- a/Telegram/SourceFiles/media/view/media_view_pip.cpp +++ b/Telegram/SourceFiles/media/view/media_view_pip.cpp @@ -354,7 +354,8 @@ QImage RotateFrameImage(QImage image, int rotation) { PipPanel::PipPanel( QWidget *parent, Fn paint) -: _parent(parent) +: PipParent(Core::App().getModalParent()) +, _parent(parent) , _paint(std::move(paint)) { setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint @@ -543,7 +544,11 @@ void PipPanel::setPositionOnScreen(Position position, QRect available) { geometry.moveTop(inner.y() + inner.height() - geometry.height()); } - setGeometry(geometry.marginsAdded(_padding)); + geometry += _padding; + + setGeometry(geometry); + setMinimumSize(geometry.size()); + setMaximumSize(geometry.size()); updateDecorations(); update(); } @@ -714,8 +719,11 @@ void PipPanel::processDrag(QPoint point) { if (clamped != valid.topLeft()) { moveAnimated(clamped); } else { + const auto newGeometry = valid.marginsAdded(_padding); _positionAnimation.stop(); - setGeometry(valid.marginsAdded(_padding)); + setGeometry(newGeometry); + setMinimumSize(newGeometry.size()); + setMaximumSize(newGeometry.size()); } } @@ -802,6 +810,8 @@ void PipPanel::updateDecorations() { _useTransparency = use; setAttribute(Qt::WA_OpaquePaintEvent, !_useTransparency); setGeometry(newGeometry); + setMinimumSize(newGeometry.size()); + setMaximumSize(newGeometry.size()); update(); } diff --git a/Telegram/SourceFiles/ui/widgets/separate_panel.cpp b/Telegram/SourceFiles/ui/widgets/separate_panel.cpp index 51e4127f22..4d4c335f41 100644 --- a/Telegram/SourceFiles/ui/widgets/separate_panel.cpp +++ b/Telegram/SourceFiles/ui/widgets/separate_panel.cpp @@ -31,7 +31,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Ui { SeparatePanel::SeparatePanel() -: _close(this, st::separatePanelClose) +: RpWidget(Core::App().getModalParent()) +, _close(this, st::separatePanelClose) , _back(this, object_ptr(this, st::separatePanelBack)) , _body(this) { setMouseTracking(true); @@ -359,18 +360,25 @@ void SeparatePanel::initGeometry(QSize size) { st::lineWidth); setAttribute(Qt::WA_OpaquePaintEvent, !_useTransparency); const auto screen = QApplication::desktop()->screenGeometry(center); - const auto rect = QRect(QPoint(), size); - setGeometry( - rect.translated(center - rect.center()).marginsAdded(_padding)); + const auto rect = [&] { + const QRect initRect(QPoint(), size); + return initRect.translated(center - initRect.center()).marginsAdded(_padding); + }(); + setGeometry(rect); + setMinimumSize(rect.size()); + setMaximumSize(rect.size()); updateControlsGeometry(); } void SeparatePanel::updateGeometry(QSize size) { - setGeometry( + const auto rect = QRect( x(), y(), _padding.left() + size.width() + _padding.right(), _padding.top() + size.height() + _padding.bottom()); + setGeometry(rect); + setMinimumSize(rect.size()); + setMaximumSize(rect.size()); updateControlsGeometry(); update(); }