diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index eda4684eb6..a5a8274189 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -720,6 +720,35 @@ bool SetXCBFrameExtents(QWindow *window, const QMargins &extents) { return true; } +bool UnsetXCBFrameExtents(QWindow *window) { + const auto native = QGuiApplication::platformNativeInterface(); + if (!native) { + return false; + } + + const auto connection = reinterpret_cast( + native->nativeResourceForIntegration(QByteArray("connection"))); + + if (!connection) { + return false; + } + + const auto frameExtentsAtom = GetXCBAtom( + connection, + kXCBFrameExtentsAtomName.utf16()); + + if (!frameExtentsAtom.has_value()) { + return false; + } + + xcb_delete_property( + connection, + window->winId(), + *frameExtentsAtom); + + return true; +} + bool SetWaylandWindowGeometry(QWindow *window, const QRect &geometry) { #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) || defined DESKTOP_APP_QT_PATCHED if (const auto waylandWindow = static_cast( @@ -1091,6 +1120,15 @@ bool SetWindowExtents(QWindow *window, const QMargins &extents) { } } +bool UnsetWindowExtents(QWindow *window) { + if (IsWayland()) { + const auto geometry = QRect(QPoint(), window->size()); + return SetWaylandWindowGeometry(window, geometry); + } else { + return UnsetXCBFrameExtents(window); + } +} + bool WindowsNeedShadow() { #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) || defined DESKTOP_APP_QT_PATCHED if (IsWayland()) { diff --git a/Telegram/SourceFiles/platform/platform_specific.h b/Telegram/SourceFiles/platform/platform_specific.h index dd4cb60204..cbdbb2ec36 100644 --- a/Telegram/SourceFiles/platform/platform_specific.h +++ b/Telegram/SourceFiles/platform/platform_specific.h @@ -58,6 +58,7 @@ bool StartSystemResize(QWindow *window, Qt::Edges edges); bool ShowWindowMenu(QWindow *window); bool WindowsNeedShadow(); bool SetWindowExtents(QWindow *window, const QMargins &extents); +bool UnsetWindowExtents(QWindow *window); Window::ControlsLayout WindowControlsLayout(); namespace ThirdParty { diff --git a/Telegram/SourceFiles/window/window_title_qt.cpp b/Telegram/SourceFiles/window/window_title_qt.cpp index 6ccee244f3..4446437a32 100644 --- a/Telegram/SourceFiles/window/window_title_qt.cpp +++ b/Telegram/SourceFiles/window/window_title_qt.cpp @@ -85,10 +85,14 @@ TitleWidgetQt::TitleWidgetQt(QWidget *parent) TitleWidgetQt::~TitleWidgetQt() { restoreCursor(); + if (!_windowWasFrameless) { toggleFramelessWindow(false); } - Platform::SetWindowExtents(window()->windowHandle(), QMargins()); + + if (_extentsSet) { + Platform::UnsetWindowExtents(window()->windowHandle()); + } } void TitleWidgetQt::toggleFramelessWindow(bool enabled) { @@ -137,10 +141,21 @@ void TitleWidgetQt::paintEvent(QPaintEvent *e) { } void TitleWidgetQt::updateWindowExtents() { - if (hasShadow() && !_maximizedState) { - Platform::SetWindowExtents(window()->windowHandle(), ShadowExtents()); - } else { - Platform::SetWindowExtents(window()->windowHandle(), QMargins()); + if (hasShadow()) { + if (!_maximizedState) { + Platform::SetWindowExtents( + window()->windowHandle(), + ShadowExtents()); + } else { + Platform::SetWindowExtents( + window()->windowHandle(), + QMargins()); + } + + _extentsSet = true; + } else if (_extentsSet) { + Platform::UnsetWindowExtents(window()->windowHandle()); + _extentsSet = false; } } diff --git a/Telegram/SourceFiles/window/window_title_qt.h b/Telegram/SourceFiles/window/window_title_qt.h index 02db001f7c..0d10865c35 100644 --- a/Telegram/SourceFiles/window/window_title_qt.h +++ b/Telegram/SourceFiles/window/window_title_qt.h @@ -66,6 +66,7 @@ private: bool _activeState = false; bool _windowWasFrameless = false; bool _cursorOverriden = false; + bool _extentsSet = false; };