From 0563e1f8781abeed98c3eb757811a86800f55b87 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 12 Nov 2020 00:54:09 +0100 Subject: [PATCH] Have the wayland build-time toggle affect the native window title --- Telegram/CMakeLists.txt | 1 + .../platform/linux/window_title_linux.cpp | 38 +++++++++++++++++++ .../platform/linux/window_title_linux.h | 12 +----- 3 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 Telegram/SourceFiles/platform/linux/window_title_linux.cpp diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 2320bd52c..215698590 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -824,6 +824,7 @@ PRIVATE platform/linux/notifications_manager_linux.h platform/linux/specific_linux.cpp platform/linux/specific_linux.h + platform/linux/window_title_linux.cpp platform/linux/window_title_linux.h platform/mac/file_utilities_mac.mm platform/mac/file_utilities_mac.h diff --git a/Telegram/SourceFiles/platform/linux/window_title_linux.cpp b/Telegram/SourceFiles/platform/linux/window_title_linux.cpp new file mode 100644 index 000000000..95e8b6449 --- /dev/null +++ b/Telegram/SourceFiles/platform/linux/window_title_linux.cpp @@ -0,0 +1,38 @@ +/* +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. + +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ +#include "platform/linux/window_title_linux.h" + +#include "platform/linux/linux_desktop_environment.h" +#include "base/platform/base_platform_info.h" + +namespace Platform { +namespace { + +bool SystemMoveResizeSupported() { +#if !defined DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION || QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) || defined DESKTOP_APP_QT_PATCHED + return true; +#else // !DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION || Qt >= 5.15 || DESKTOP_APP_QT_PATCHED + return !IsWayland(); +#endif // !DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION || Qt >= 5.15 || DESKTOP_APP_QT_PATCHED +} + +} // namespace + +bool AllowNativeWindowFrameToggle() { + return SystemMoveResizeSupported() + // https://gitlab.gnome.org/GNOME/mutter/-/issues/217 + && !(DesktopEnvironment::IsGnome() && IsWayland()); +} + +object_ptr CreateTitleWidget(QWidget *parent) { + return SystemMoveResizeSupported() + ? object_ptr(parent) + : object_ptr{ nullptr }; +} + +} // namespace Platform diff --git a/Telegram/SourceFiles/platform/linux/window_title_linux.h b/Telegram/SourceFiles/platform/linux/window_title_linux.h index 4e5f68e02..c493976c2 100644 --- a/Telegram/SourceFiles/platform/linux/window_title_linux.h +++ b/Telegram/SourceFiles/platform/linux/window_title_linux.h @@ -8,8 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #pragma once #include "platform/platform_window_title.h" -#include "platform/linux/linux_desktop_environment.h" -#include "base/platform/base_platform_info.h" #include "base/object_ptr.h" namespace Window { @@ -23,14 +21,8 @@ void DefaultPreviewWindowFramePaint(QImage &preview, const style::palette &palet namespace Platform { -inline bool AllowNativeWindowFrameToggle() { - // https://gitlab.gnome.org/GNOME/mutter/-/issues/217 - return !(DesktopEnvironment::IsGnome() && IsWayland()); -} - -inline object_ptr CreateTitleWidget(QWidget *parent) { - return object_ptr(parent); -} +bool AllowNativeWindowFrameToggle(); +object_ptr CreateTitleWidget(QWidget *parent); inline bool NativeTitleRequiresShadow() { return false;