Improve media viewer hiding workaround on macOS.

This commit is contained in:
John Preston 2020-11-19 17:59:43 +03:00
parent 51f960442e
commit e29ee439cf
2 changed files with 25 additions and 19 deletions

View file

@ -4295,24 +4295,7 @@ bool OverlayWidget::eventFilter(QObject *obj, QEvent *e) {
return OverlayParent::eventFilter(obj, e);
}
void OverlayWidget::setVisibleHook(bool visible) {
if (!visible) {
_sharedMedia = nullptr;
_sharedMediaData = std::nullopt;
_sharedMediaDataKey = std::nullopt;
_userPhotos = nullptr;
_userPhotosData = std::nullopt;
_collage = nullptr;
_collageData = std::nullopt;
assignMediaPointer(nullptr);
_preloadPhotos.clear();
_preloadDocuments.clear();
if (_menu) _menu->hideMenu(true);
_controlsHideTimer.stop();
_controlsState = ControlsShown;
_controlsOpacity = anim::value(1, 1);
_groupThumbs = nullptr;
_groupThumbsRect = QRect();
void OverlayWidget::applyHideWindowWorkaround() {
#ifdef USE_OPENGL_OVERLAY_WIDGET
// QOpenGLWidget can't properly destroy a child widget if
// it is hidden exactly after that, so it must be repainted
@ -4333,6 +4316,27 @@ void OverlayWidget::setVisibleHook(bool visible) {
}
#endif // USE_OPENGL_OVERLAY_WIDGET
}
void OverlayWidget::setVisibleHook(bool visible) {
if (!visible) {
applyHideWindowWorkaround();
_sharedMedia = nullptr;
_sharedMediaData = std::nullopt;
_sharedMediaDataKey = std::nullopt;
_userPhotos = nullptr;
_userPhotosData = std::nullopt;
_collage = nullptr;
_collageData = std::nullopt;
assignMediaPointer(nullptr);
_preloadPhotos.clear();
_preloadDocuments.clear();
if (_menu) _menu->hideMenu(true);
_controlsHideTimer.stop();
_controlsState = ControlsShown;
_controlsOpacity = anim::value(1, 1);
_groupThumbs = nullptr;
_groupThumbsRect = QRect();
}
OverlayParent::setVisibleHook(visible);
if (visible) {
QCoreApplication::instance()->installEventFilter(this);

View file

@ -372,6 +372,8 @@ private:
void clearStreaming(bool savePosition = true);
bool canInitStreaming() const;
void applyHideWindowWorkaround();
QBrush _transparentBrush;
Main::Session *_session = nullptr;