Change flags / attributes when changing window frame.

This commit is contained in:
John Preston 2020-10-02 16:17:53 +03:00
parent d965385356
commit 18cb26fed6
3 changed files with 22 additions and 7 deletions

View File

@ -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() {

View File

@ -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;
}

View File

@ -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);