All checks were successful
Desktop source guards / guards (push) Successful in 4s
Причина закрытия приложения при первом удалении: GPU-виджет эффекта добавлялся в уже показанное главное окно, Qt пересоздавал его нативный хэндл, WM_DESTROY принимался за закрытие (Core::Quit), а MainWindow ещё и кеширует хэндл (psHwnd, рамка, тени, панель задач), так что просто игнорировать закрытие нельзя. Если же переводить на GPU-композицию всё главное окно (праймер lib_ui), каждый кадр ждёт вертикальной синхронизации и анимации падают до ~30 кадров/с на 60 Гц (lib_ui 6d6e1f0 убрал праймер намеренно). Теперь на Windows поверхность создаётся внутри ThanosOverlay: прозрачного, не принимающего ввод и фокус окна-владельца (Qt::Tool с родителем), которое накрывает клиентскую область главного окна и создаётся уже вместе со своим GPU-потомком, поэтому Qt ничего не пересоздаёт. Главное окно не меняется. На других платформах прежний код. Аварийный выключатель: ZSG_DISABLE_THANOS=1 или «Энергосбережение → Эффекты в чатах». Диагностика core/zsg_diag пишет состояние накладки. Гарды в test_zastogram_diag.py. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
74 lines
1.9 KiB
C++
74 lines
1.9 KiB
C++
/*
|
||
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 "base/unique_qptr.h"
|
||
#include "base/weak_ptr.h"
|
||
#include "ui/effects/animations.h"
|
||
#include "ui/effects/zsg_thanos_overlay.h"
|
||
|
||
#include <QImage>
|
||
#include <QPointer>
|
||
|
||
namespace Ui {
|
||
class RpWidget;
|
||
class RpWidgetWrap;
|
||
} // namespace Ui
|
||
|
||
namespace Ui {
|
||
|
||
class ThanosEffectRenderer;
|
||
|
||
class ThanosEffect final : public base::has_weak_ptr {
|
||
public:
|
||
explicit ThanosEffect(not_null<QWidget*> parent);
|
||
~ThanosEffect();
|
||
|
||
void addItem(QImage snapshot, QRect rect);
|
||
|
||
[[nodiscard]] bool animating() const;
|
||
|
||
[[nodiscard]] rpl::producer<> allDone() const;
|
||
[[nodiscard]] static bool FailedOnce();
|
||
|
||
void setGeometry(QRect rect);
|
||
void raise();
|
||
|
||
[[nodiscard]] static bool Supported();
|
||
[[nodiscard]] static bool WindowVisible(QWidget *window);
|
||
// Runs the (potentially slow, 10–300ms) QRhi capability probe
|
||
// synchronously on the main thread and caches the result. Safe to
|
||
// call multiple times. If not called, `Supported()` will lazily
|
||
// probe on first use — prefer warming it up during idle time so the
|
||
// first message deletion doesn't hitch.
|
||
static void WarmUp();
|
||
|
||
private:
|
||
void ensureSurface();
|
||
void showSurface();
|
||
void hideSurface();
|
||
void finishNow();
|
||
[[nodiscard]] QWidget *surfaceWidget() const;
|
||
|
||
const not_null<QWidget*> _parent;
|
||
|
||
// ZaStoGram (Windows): the surface lives in this window instead of the
|
||
// main window, see zsg_thanos_overlay.h. Owned by _parent as a Qt child.
|
||
QPointer<ThanosOverlay> _overlay;
|
||
std::unique_ptr<RpWidgetWrap> _surface;
|
||
ThanosEffectRenderer *_renderer = nullptr;
|
||
bool _shown = false;
|
||
|
||
Ui::Animations::Basic _animation;
|
||
|
||
rpl::event_stream<> _allDone;
|
||
rpl::lifetime _lifetime;
|
||
|
||
};
|
||
|
||
} // namespace Ui
|