Description: Make build against Qt5 possible The patch partially reverts upstream commit e5d8a1aa3c and adds the TWidget::setScreen() method to call to a private API freely available in Qt6. Author: Nicholas Guriev Last-Update: Fri, 22 Apr 2022 22:30:22 +0300 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -499,7 +499,7 @@ void OverlayWidget::moveToScreen(bool in DEBUG_LOG(("Viewer Pos: Currently on screen %1, moving to screen %2") .arg(screenList.indexOf(myScreen)) .arg(screenList.indexOf(activeWindowScreen))); - _widget->setScreen(activeWindowScreen); + window()->setScreen(activeWindowScreen); DEBUG_LOG(("Viewer Pos: New actual screen: %1") .arg(screenList.indexOf(_widget->screen()))); } --- a/Telegram/SourceFiles/media/view/media_view_pip.cpp +++ b/Telegram/SourceFiles/media/view/media_view_pip.cpp @@ -475,7 +475,7 @@ void PipPanel::setPositionDefault() { const auto parentScreen = widgetScreen(_parent); const auto myScreen = widgetScreen(widget()); if (parentScreen && myScreen && myScreen != parentScreen) { - widget()->setScreen(parentScreen); + widget()->windowHandle()->setScreen(parentScreen); } auto position = Position(); position.snapped = RectPart::Top | RectPart::Left; --- a/Telegram/lib_ui/ui/rp_widget.cpp +++ b/Telegram/lib_ui/ui/rp_widget.cpp @@ -11,6 +11,8 @@ #include #include +#include + namespace Ui { namespace { @@ -207,3 +209,12 @@ auto RpWidgetWrap::eventStreams() const } } // namespace Ui + +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + +bool TWidget::setScreen(QScreen *next) { + // This method becomes public in Qt6. So anyway reveal it right here. + return qt_widget_private(this)->setScreen(next); +} + +#endif // Qt < 6.0.0 --- a/Telegram/lib_ui/ui/rp_widget.h +++ b/Telegram/lib_ui/ui/rp_widget.h @@ -206,6 +206,10 @@ public: return rectNoMargins().size(); } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + bool setScreen(QScreen*); +#endif // Qt < 6.0.0 + // Updates the area that is visible inside the scroll container. void setVisibleTopBottom(int visibleTop, int visibleBottom) { auto max = height();