Fix PiP window on macOS.

This commit is contained in:
John Preston 2020-01-29 18:54:40 +03:00
parent 0fbd263562
commit 4d737b35da
5 changed files with 11 additions and 10 deletions

View File

@ -706,7 +706,6 @@ void Panel::paintEvent(QPaintEvent *e) {
finishAnimating(); finishAnimating();
if (!_call || isHidden()) return; if (!_call || isHidden()) return;
} else { } else {
Ui::Platform::StartTranslucentPaint(p, e);
p.setOpacity(opacity); p.setOpacity(opacity);
PainterHighQualityEnabler hq(p); PainterHighQualityEnabler hq(p);
@ -719,7 +718,6 @@ void Panel::paintEvent(QPaintEvent *e) {
} }
if (_useTransparency) { if (_useTransparency) {
Ui::Platform::StartTranslucentPaint(p, e);
p.drawPixmapLeft(0, 0, width(), _cache); p.drawPixmapLeft(0, 0, width(), _cache);
} else { } else {
p.drawPixmapLeft(_padding.left(), _padding.top(), width(), _userPhoto); p.drawPixmapLeft(_padding.left(), _padding.top(), width(), _userPhoto);

View File

@ -2522,6 +2522,9 @@ void OverlayWidget::switchToPip() {
closeAndContinue, closeAndContinue,
[=] { _pip = nullptr; }); [=] { _pip = nullptr; });
close(); close();
if (const auto window = Core::App().activeWindow()) {
window->activate();
}
} }
void OverlayWidget::playbackToggleFullScreen() { void OverlayWidget::playbackToggleFullScreen() {

View File

@ -260,11 +260,11 @@ PipPanel::PipPanel(
setAttribute(Qt::WA_MacAlwaysShowToolWindow); setAttribute(Qt::WA_MacAlwaysShowToolWindow);
setAttribute(Qt::WA_NoSystemBackground); setAttribute(Qt::WA_NoSystemBackground);
setAttribute(Qt::WA_TranslucentBackground); setAttribute(Qt::WA_TranslucentBackground);
Ui::Platform::IgnoreAllActivation(this);
Ui::Platform::InitOnTopPanel(this); Ui::Platform::InitOnTopPanel(this);
setMouseTracking(true); setMouseTracking(true);
resize(0, 0); resize(0, 0);
show(); show();
//Ui::Platform::IgnoreAllActivation(this);
} }
void PipPanel::setAspectRatio(QSize ratio) { void PipPanel::setAspectRatio(QSize ratio) {
@ -429,12 +429,12 @@ void PipPanel::paintEvent(QPaintEvent *e) {
QPainter p(this); QPainter p(this);
if (_useTransparency) { if (_useTransparency) {
Ui::Platform::StartTranslucentPaint(p, e); Ui::Platform::StartTranslucentPaint(p, e->region().rects());
} }
auto request = FrameRequest(); auto request = FrameRequest();
const auto inner = rect().marginsRemoved(_padding); const auto inner = rect().marginsRemoved(_padding);
request.resize = request.outer = inner.size(); request.resize = request.outer = inner.size() * style::DevicePixelRatio();
request.corners = RectPart(0) request.corners = RectPart(0)
| ((_attached & (RectPart::Left | RectPart::Top)) | ((_attached & (RectPart::Left | RectPart::Top))
? RectPart(0) ? RectPart(0)
@ -728,7 +728,9 @@ void Pip::setupPanel() {
) | rpl::filter([=](not_null<QEvent*> e) { ) | rpl::filter([=](not_null<QEvent*> e) {
return e->type() == QEvent::Close; return e->type() == QEvent::Close;
}) | rpl::start_with_next([=] { }) | rpl::start_with_next([=] {
_destroy(); crl::on_main(&_panel, [=] {
_destroy();
});
}, _panel.lifetime()); }, _panel.lifetime());
} }
@ -786,7 +788,7 @@ void Pip::setupStreaming() {
void Pip::paint(QPainter &p, FrameRequest request) { void Pip::paint(QPainter &p, FrameRequest request) {
const auto image = videoFrameForDirectPaint(request); const auto image = videoFrameForDirectPaint(request);
p.drawImage(0, 0, image); p.drawImage(QRect{ QPoint(), request.outer / style::DevicePixelRatio() }, image);
if (_instance.player().ready()) { if (_instance.player().ready()) {
_instance.markFrameShown(); _instance.markFrameShown();
} }

View File

@ -398,7 +398,6 @@ void SeparatePanel::paintEvent(QPaintEvent *e) {
finishAnimating(); finishAnimating();
if (isHidden()) return; if (isHidden()) return;
} else { } else {
Ui::Platform::StartTranslucentPaint(p, e);
p.setOpacity(opacity); p.setOpacity(opacity);
PainterHighQualityEnabler hq(p); PainterHighQualityEnabler hq(p);
@ -419,7 +418,6 @@ void SeparatePanel::paintEvent(QPaintEvent *e) {
} }
if (_useTransparency) { if (_useTransparency) {
Ui::Platform::StartTranslucentPaint(p, e);
paintShadowBorder(p); paintShadowBorder(p);
} else { } else {
paintOpaqueBorder(p); paintOpaqueBorder(p);

@ -1 +1 @@
Subproject commit 8399f70ea0764ff8ebc4928474c311b6327da802 Subproject commit 33ea14969edfbe2546726d82925a1a66ae49310e