Apply sway fixes to the PiP and export windows too

This commit is contained in:
Ilya Fedin 2020-05-29 23:36:04 +04:00 committed by John Preston
parent 7b106761be
commit 586744c112
2 changed files with 26 additions and 8 deletions

View File

@ -354,7 +354,8 @@ QImage RotateFrameImage(QImage image, int rotation) {
PipPanel::PipPanel(
QWidget *parent,
Fn<void(QPainter&, FrameRequest)> 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();
}

View File

@ -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<Ui::IconButton>(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();
}