From 18cb26fed6080a66c39531a02d337380588f2852 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 2 Oct 2020 16:17:53 +0300 Subject: [PATCH] Change flags / attributes when changing window frame. --- Telegram/SourceFiles/window/main_window.cpp | 15 +++++++++++++++ Telegram/SourceFiles/window/window_title_qt.cpp | 8 +------- Telegram/SourceFiles/window/window_title_qt.h | 6 ++++++ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Telegram/SourceFiles/window/main_window.cpp b/Telegram/SourceFiles/window/main_window.cpp index 6c5fe237e..47cd7ebb6 100644 --- a/Telegram/SourceFiles/window/main_window.cpp +++ b/Telegram/SourceFiles/window/main_window.cpp @@ -363,6 +363,21 @@ void MainWindow::refreshTitleWidget() { _title->init(); _titleShadow.destroy(); } + +#ifdef Q_OS_LINUX + // setWindowFlag calls setParent(parentWidget(), newFlags), which + // always calls hide() explicitly, we have to show() the window back. + const auto hidden = isHidden(); + const auto withShadow = hasShadow(); + setWindowFlag(Qt::NoDropShadowWindowHint, withShadow); + setAttribute(Qt::WA_OpaquePaintEvent, !withShadow); + if (!hidden) { + base::call_delayed( + kShowAfterWindowFlagChangeDelay, + this, + [=] { show(); }); + } +#endif // Q_OS_LINUX } void MainWindow::updateMinimumSize() { diff --git a/Telegram/SourceFiles/window/window_title_qt.cpp b/Telegram/SourceFiles/window/window_title_qt.cpp index 45d887dff..e6bcd4d18 100644 --- a/Telegram/SourceFiles/window/window_title_qt.cpp +++ b/Telegram/SourceFiles/window/window_title_qt.cpp @@ -24,13 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Window { namespace { -// If we toggle frameless window hint in maximized window, and -// show it back too quickly, the mouse position inside the window -// won't be correct (from Qt-s point of view) until we Alt-Tab from -// that window. If we show the window back with this delay it works. -constexpr auto kShowAfterFramelessToggleDelay = crl::time(1000); - -style::margins ShadowExtents() { +[[nodiscard]] style::margins ShadowExtents() { return st::callShadow.extend; } diff --git a/Telegram/SourceFiles/window/window_title_qt.h b/Telegram/SourceFiles/window/window_title_qt.h index 0d10865c3..40f823b0b 100644 --- a/Telegram/SourceFiles/window/window_title_qt.h +++ b/Telegram/SourceFiles/window/window_title_qt.h @@ -22,6 +22,12 @@ class PlainShadow; namespace Window { +// If we toggle frameless window hint in maximized window, and +// show it back too quickly, the mouse position inside the window +// won't be correct (from Qt-s point of view) until we Alt-Tab from +// that window. If we show the window back with this delay it works. +inline constexpr auto kShowAfterWindowFlagChangeDelay = crl::time(1000); + class TitleWidgetQt : public TitleWidget { public: TitleWidgetQt(QWidget *parent);