diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 29c5b88884..5c2555b98f 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -843,6 +843,7 @@ PRIVATE platform/linux/notifications_manager_linux.h platform/linux/specific_linux.cpp platform/linux/specific_linux.h + platform/linux/window_title_linux.h platform/mac/file_utilities_mac.mm platform/mac/file_utilities_mac.h platform/mac/launcher_mac.mm diff --git a/Telegram/SourceFiles/platform/linux/window_title_linux.h b/Telegram/SourceFiles/platform/linux/window_title_linux.h new file mode 100644 index 0000000000..19b2e9d069 --- /dev/null +++ b/Telegram/SourceFiles/platform/linux/window_title_linux.h @@ -0,0 +1,43 @@ +/* +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 +*/ +#pragma once + +#include "platform/platform_window_title.h" +#include "platform/linux/linux_desktop_environment.h" +#include "base/object_ptr.h" + +namespace Window { +namespace Theme { + +int DefaultPreviewTitleHeight(); +void DefaultPreviewWindowFramePaint(QImage &preview, const style::palette &palette, QRect body, int outerWidth); + +} // namespace Theme +} // namespace Window + +namespace Platform { + +inline object_ptr CreateTitleWidget(QWidget *parent) { +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) || defined DESKTOP_APP_QT_PATCHED + if (!DesktopEnvironment::IsUnity()) { + return object_ptr(parent); + } +#endif // Qt >= 5.15 || DESKTOP_APP_QT_PATCHED + + return { nullptr }; +} + +inline int PreviewTitleHeight() { + return Window::Theme::DefaultPreviewTitleHeight(); +} + +inline void PreviewWindowFramePaint(QImage &preview, const style::palette &palette, QRect body, int outerWidth) { + return Window::Theme::DefaultPreviewWindowFramePaint(preview, palette, body, outerWidth); +} + +} // namespace Platform diff --git a/Telegram/SourceFiles/platform/platform_window_title.h b/Telegram/SourceFiles/platform/platform_window_title.h index 465db8d736..1af12c8256 100644 --- a/Telegram/SourceFiles/platform/platform_window_title.h +++ b/Telegram/SourceFiles/platform/platform_window_title.h @@ -27,7 +27,9 @@ void PreviewWindowFramePaint(QImage &preview, const style::palette &palette, QRe #include "platform/mac/window_title_mac.h" #elif defined Q_OS_WIN // Q_OS_MAC #include "platform/win/window_title_win.h" -#else // Q_OS_MAC || Q_OS_WIN +#elif defined Q_OS_UNIX // Q_OS_MAC || Q_OS_WIN +#include "platform/linux/window_title_linux.h" +#else // Q_OS_MAC || Q_OS_WIN || Q_OS_UNIX namespace Platform { @@ -49,4 +51,4 @@ inline void PreviewWindowFramePaint(QImage &preview, const style::palette &palet } // namespace Platform -#endif // Q_OS_MAC || Q_OS_WIN +#endif // Q_OS_MAC || Q_OS_WIN || Q_OS_UNIX diff --git a/Telegram/SourceFiles/ui/widgets/separate_panel.cpp b/Telegram/SourceFiles/ui/widgets/separate_panel.cpp index 0de4edeb54..efbf6c98f1 100644 --- a/Telegram/SourceFiles/ui/widgets/separate_panel.cpp +++ b/Telegram/SourceFiles/ui/widgets/separate_panel.cpp @@ -555,12 +555,15 @@ void SeparatePanel::mousePressEvent(QMouseEvent *e) { if (e->button() == Qt::LeftButton) { if (dragArea.contains(e->pos())) { #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) || defined DESKTOP_APP_QT_PATCHED - windowHandle()->startSystemMove(); + const auto dragViaSystem = windowHandle()->startSystemMove(); #else // Qt >= 5.15 || DESKTOP_APP_QT_PATCHED - _dragging = true; - _dragStartMousePosition = e->globalPos(); - _dragStartMyPosition = QPoint(x(), y()); + const auto dragViaSystem = false; #endif // Qt < 5.15 && !DESKTOP_APP_QT_PATCHED + if (!dragViaSystem) { + _dragging = true; + _dragStartMousePosition = e->globalPos(); + _dragStartMyPosition = QPoint(x(), y()); + } } else if (!rect().contains(e->pos()) && _hideOnDeactivate) { LOG(("Export Info: Panel Hide On Click.")); hideGetDuration(); @@ -569,7 +572,6 @@ void SeparatePanel::mousePressEvent(QMouseEvent *e) { } void SeparatePanel::mouseMoveEvent(QMouseEvent *e) { -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) && !defined DESKTOP_APP_QT_PATCHED if (_dragging) { if (!(e->buttons() & Qt::LeftButton)) { _dragging = false; @@ -578,15 +580,12 @@ void SeparatePanel::mouseMoveEvent(QMouseEvent *e) { + (e->globalPos() - _dragStartMousePosition)); } } -#endif // Qt < 5.15 && !DESKTOP_APP_QT_PATCHED } void SeparatePanel::mouseReleaseEvent(QMouseEvent *e) { -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) && !defined DESKTOP_APP_QT_PATCHED - if (e->button() == Qt::LeftButton) { + if (e->button() == Qt::LeftButton && _dragging) { _dragging = false; } -#endif // Qt < 5.15 && !DESKTOP_APP_QT_PATCHED } void SeparatePanel::leaveEventHook(QEvent *e) { diff --git a/Telegram/SourceFiles/ui/widgets/separate_panel.h b/Telegram/SourceFiles/ui/widgets/separate_panel.h index 9be8191dce..92608fac1c 100644 --- a/Telegram/SourceFiles/ui/widgets/separate_panel.h +++ b/Telegram/SourceFiles/ui/widgets/separate_panel.h @@ -93,11 +93,9 @@ private: bool _useTransparency = true; style::margins _padding; -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) && !defined DESKTOP_APP_QT_PATCHED bool _dragging = false; QPoint _dragStartMousePosition; QPoint _dragStartMyPosition; -#endif // Qt < 5.15 && !DESKTOP_APP_QT_PATCHED Ui::Animations::Simple _titleLeft; bool _visible = false;