From ada377201e475fc71fc01d65cef47e7738296bf0 Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Tue, 30 Aug 2022 16:32:54 +0800 Subject: [PATCH 17/17] Revert "Client: Don't send fake SurfaceCreated/Destroyed events" This reverts commit cd21404f99b486ff62225699e1a4bdc0d5b3d5c1. Others, e.g. Quick scenegraph, still need surfaceAboutToBeDestroyed event to cleanup renderer resources. Signed-off-by: Jeffy Chen --- src/client/qwaylandwindow.cpp | 10 ++++++++-- src/client/qwaylandwindow_p.h | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index c71d709..e23af43 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -97,7 +97,7 @@ QWaylandWindow::~QWaylandWindow() delete mWindowDecoration; if (mSurface) - reset(); + reset(false); const QWindow *parent = window(); const auto tlw = QGuiApplication::topLevelWindows(); @@ -153,6 +153,8 @@ void QWaylandWindow::initWindow() if (!mSurface) { initializeWlSurface(); + QPlatformSurfaceEvent e(QPlatformSurfaceEvent::SurfaceCreated); + QGuiApplication::sendEvent(window(), &e); } if (shouldCreateSubSurface()) { @@ -286,8 +288,12 @@ bool QWaylandWindow::shouldCreateSubSurface() const return QPlatformWindow::parent() != nullptr; } -void QWaylandWindow::reset() +void QWaylandWindow::reset(bool sendDestroyEvent) { + if (mSurface && sendDestroyEvent) { + QPlatformSurfaceEvent e(QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed); + QGuiApplication::sendEvent(window(), &e); + } mWaitingToApplyConfigure = false; delete mShellSurface; diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h index 7f52192..27ff0d4 100644 --- a/src/client/qwaylandwindow_p.h +++ b/src/client/qwaylandwindow_p.h @@ -273,7 +273,7 @@ private: void initializeWlSurface(); bool shouldCreateShellSurface() const; bool shouldCreateSubSurface() const; - void reset(); + void reset(bool sendDestroyEvent = true); void sendExposeEvent(const QRect &rect); static void closePopups(QWaylandWindow *parent); QPlatformScreen *calculateScreenFromSurfaceEvents() const; -- 2.20.1