diff --git a/Telegram/SourceFiles/media/view/media_view_pip.cpp b/Telegram/SourceFiles/media/view/media_view_pip.cpp index 8fd911964adf2..0975b5c6f101e 100644 --- a/Telegram/SourceFiles/media/view/media_view_pip.cpp +++ b/Telegram/SourceFiles/media/view/media_view_pip.cpp @@ -24,7 +24,6 @@ For license and copyright information please follow this link: #include "core/application.h" #include "base/platform/base_platform_info.h" #include "base/power_save_blocker.h" -#include "base/event_filter.h" #include "ui/platform/ui_platform_utility.h" #include "ui/platform/ui_platform_window_title.h" #include "ui/widgets/buttons.h" @@ -351,7 +350,6 @@ void PipPanel::init() { widget()->setMouseTracking(true); widget()->resize(0, 0); widget()->hide(); - widget()->createWinId(); rp()->shownValue( ) | rpl::filter([=](bool shown) { @@ -368,30 +366,9 @@ void PipPanel::init() { if (Platform::IsWayland()) { rp()->sizeValue( - ) | rpl::start_with_next([=](QSize size) { + ) | rpl::skip(1) | rpl::start_with_next([=](QSize size) { handleWaylandResize(size); }, rp()->lifetime()); - - base::install_event_filter(widget(), [=](not_null event) { - if (event->type() == QEvent::Resize && _inHandleWaylandResize) { - return base::EventFilterResult::Cancel; - } - return base::EventFilterResult::Continue; - }); - - base::install_event_filter(widget()->windowHandle(), [=](not_null event) { - if (event->type() == QEvent::Resize) { - if (_inHandleWaylandResize) { - return base::EventFilterResult::Cancel; - } - const auto newSize = static_cast(event.get())->size(); - if (_suggestedWaylandSize == newSize) { - handleWaylandResize(newSize); - return base::EventFilterResult::Cancel; - } - } - return base::EventFilterResult::Continue; - }); } } @@ -610,8 +587,10 @@ void PipPanel::setGeometry(QRect geometry) { } void PipPanel::handleWaylandResize(QSize size) { + if (_inHandleWaylandResize) { + return; + } _inHandleWaylandResize = true; - _suggestedWaylandSize = size; // Apply aspect ratio. const auto max = std::max(size.width(), size.height()); @@ -632,6 +611,8 @@ void PipPanel::handleWaylandResize(QSize size) { : scaled; widget()->resize(normalized); + QResizeEvent e(normalized, size); + QCoreApplication::sendEvent(widget()->windowHandle(), &e); _inHandleWaylandResize = false; } diff --git a/Telegram/SourceFiles/media/view/media_view_pip.h b/Telegram/SourceFiles/media/view/media_view_pip.h index efcb326f4dd2d..d0156e1bd224a 100644 --- a/Telegram/SourceFiles/media/view/media_view_pip.h +++ b/Telegram/SourceFiles/media/view/media_view_pip.h @@ -106,7 +106,6 @@ class PipPanel final { bool _useTransparency = true; bool _dragDisabled = false; bool _inHandleWaylandResize = false; - QSize _suggestedWaylandSize; style::margins _padding; RectPart _overState = RectPart();