Add aboutToBeDestroyed signal to various xdg-shell classes

With the aboutToBeDestroyed signal, the compositor will be able to
perform cleanup before the QObject::destroyed signal is emitted, which
saves us some nullptr checks.
This commit is contained in:
Vlad Zahorodnii 2021-08-12 13:10:20 +03:00
parent 6ba9856a29
commit d0a0c70d9c
2 changed files with 18 additions and 0 deletions

View file

@ -182,6 +182,7 @@ XdgSurfaceInterfacePrivate *XdgSurfaceInterfacePrivate::get(XdgSurfaceInterface
void XdgSurfaceInterfacePrivate::xdg_surface_destroy_resource(Resource *resource)
{
Q_UNUSED(resource)
Q_EMIT q->aboutToBeDestroyed();
XdgShellInterfacePrivate::get(shell)->unregisterXdgSurface(q);
delete q;
}
@ -374,6 +375,7 @@ void XdgToplevelInterfacePrivate::reset()
void XdgToplevelInterfacePrivate::xdg_toplevel_destroy_resource(Resource *resource)
{
Q_UNUSED(resource)
Q_EMIT q->aboutToBeDestroyed();
delete q;
}
@ -695,6 +697,7 @@ void XdgPopupInterfacePrivate::reset()
void XdgPopupInterfacePrivate::xdg_popup_destroy_resource(Resource *resource)
{
Q_UNUSED(resource)
Q_EMIT q->aboutToBeDestroyed();
delete q;
}

View file

@ -162,6 +162,11 @@ public:
static XdgSurfaceInterface *get(::wl_resource *resource);
Q_SIGNALS:
/**
* This signal is emitted when the xdg-surface is about to be destroyed.
*/
void aboutToBeDestroyed();
/**
* This signal is emitted when a configure event with serial \a serial has been acknowledged.
*/
@ -280,6 +285,11 @@ public:
static XdgToplevelInterface *get(::wl_resource *resource);
Q_SIGNALS:
/**
* This signal is emitted when the xdg-toplevel is about to be destroyed.
*/
void aboutToBeDestroyed();
/**
* This signal is emitted when the xdg-toplevel has commited the initial state and wants to
* be configured. After initializing the toplevel, you must send a configure event.
@ -537,6 +547,11 @@ public:
static XdgPopupInterface *get(::wl_resource *resource);
Q_SIGNALS:
/**
* This signal is emitted when the xdg-popup is about to be destroyed.
*/
void aboutToBeDestroyed();
/**
* This signal is emitted when the xdg-popup has commited the initial state and wants to
* be configured. After initializing the popup, you must send a configure event.