From 1791b251ad73f492b3e62e0c1b8ac8c2092cf311 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 21 Jun 2017 13:49:10 +0300 Subject: [PATCH] Fix tabbed section / panel render glitches. --- Telegram/SourceFiles/historywidget.cpp | 17 +++++++++++++++++ Telegram/SourceFiles/mainwidget.cpp | 15 --------------- Telegram/SourceFiles/ui/twidget.cpp | 5 +++++ Telegram/SourceFiles/window/window_controller.h | 4 ++++ 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index a77faa8e5..ef8f79891 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -665,6 +665,22 @@ HistoryWidget::HistoryWidget(QWidget *parent, gsl::not_null onPreviewCheck(); } })); + subscribe(controller->widgetGrabbed(), [this] { + // Qt bug workaround: QWidget::render() for an arbitrary widget calls + // sendPendingMoveAndResizeEvents(true, true) for the whole window, + // which does something like: + // + // setAttribute(Qt::WA_UpdatesDisabled); + // sendEvent(QResizeEvent); + // setAttribute(Qt::WA_UpdatesDisabled, false); + // + // So if we create TabbedSection widget in HistoryWidget::resizeEvent() + // it will get an enabled Qt::WA_UpdatesDisabled from its parent and it + // will never be rendered, because no one will ever remove that attribute. + // + // So we force HistoryWidget::resizeEvent() here, without WA_UpdatesDisabled. + myEnsureResized(this); + }); orderWidgets(); } @@ -3971,6 +3987,7 @@ void HistoryWidget::updateTabbedSelectorSectionShown() { updateControlsVisibility(); } else { _tabbedPanel.create(this, controller(), _tabbedSection->takeSelector()); + _tabbedPanel->hide(); _tabbedSelectorToggle->installEventFilter(_tabbedPanel); _tabbedSection.destroy(); _tabbedSelectorToggle->setColorOverrides(nullptr, nullptr, nullptr); diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index dd6b98ff6..c1acd5c78 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -2567,21 +2567,6 @@ void MainWidget::ui_showPeerHistory(quint64 peerId, qint32 showAtMsgId, Ui::Show return false; }; - // Qt bug workaround: QWidget::render() for an arbitrary widget calls - // sendPendingMoveAndResizeEvents(true, true) for the whole window, - // which does something like: - // - // setAttribute(Qt::WA_UpdatesDisabled); - // sendEvent(QResizeEvent); - // setAttribute(Qt::WA_UpdatesDisabled, false); - // - // So if we create TabbedSection widget in HistoryWidget::resizeEvent() - // it will get an enabled Qt::WA_UpdatesDisabled from its parent and it - // will never be rendered, because no one will ever remove that attribute. - // - // So we force HistoryWidget::resizeEvent() here, without WA_UpdatesDisabled. - myEnsureResized(_history); - auto animationParams = animatedShow() ? prepareHistoryAnimation(peerId) : Window::SectionSlideParams(); if (_history->peer() && _history->peer()->id != peerId && way != Ui::ShowWay::Forward) { diff --git a/Telegram/SourceFiles/ui/twidget.cpp b/Telegram/SourceFiles/ui/twidget.cpp index 04fad32ba..6d22f1d2f 100644 --- a/Telegram/SourceFiles/ui/twidget.cpp +++ b/Telegram/SourceFiles/ui/twidget.cpp @@ -18,8 +18,11 @@ to link the code of portions of this program with the OpenSSL library. Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org */ +#include "twidget.h" + #include "application.h" #include "mainwindow.h" +#include "window/window_controller.h" namespace Fonts { namespace { @@ -153,6 +156,8 @@ QPixmap myGrab(TWidget *target, QRect rect, QColor bg) { result.fill(bg); } + App::wnd()->controller()->widgetGrabbed().notify(true); + target->grabStart(); target->render(&result, QPoint(0, 0), rect, QWidget::DrawChildren | QWidget::IgnoreMask); target->grabFinish(); diff --git a/Telegram/SourceFiles/window/window_controller.h b/Telegram/SourceFiles/window/window_controller.h index 4fb289e44..b4ff1460f 100644 --- a/Telegram/SourceFiles/window/window_controller.h +++ b/Telegram/SourceFiles/window/window_controller.h @@ -68,6 +68,9 @@ public: base::Observable &floatPlayerAreaUpdated() { return _floatPlayerAreaUpdated; } + base::Observable &widgetGrabbed() { + return _widgetGrabbed; + } struct ColumnLayout { int bodyWidth; @@ -108,6 +111,7 @@ private: GifPauseReasons _gifPauseReasons = { 0 }; base::Observable _gifPauseLevelChanged; base::Observable _floatPlayerAreaUpdated; + base::Observable _widgetGrabbed; base::Variable _dialogsWidthRatio = { kDefaultDialogsWidthRatio }; base::Variable _dialogsListFocused = { false };