Send SurfaceCreated and SurfaceAboutToBeDestroyed events for wl_surface
Previously, the events were matching the life cycle of QWaylandWindow. This commit changes it so the events are matching the life cycle of wl_surfaces instead (a QWaylandWindow can outlive several wl_surfaces). Some of these events were already sent in QWindowPrivate (the first and last). Now we handle the cases where the wl_surface is destroyed and recreated due to hiding/showing the window or when changing the role of the wl_surface. Task-number: QTBUG-58423 Change-Id: Ie4a4e7dd529e1a41a2cf42e02cebb3c8aca4a4cc Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com> Reviewed-by: Marco Martin <notmart@gmail.com>
This commit is contained in:
parent
fbec715de2
commit
57af7c4c22
@ -110,7 +110,7 @@ QWaylandWindow::~QWaylandWindow()
|
|||||||
delete mWindowDecoration;
|
delete mWindowDecoration;
|
||||||
|
|
||||||
if (isInitialized())
|
if (isInitialized())
|
||||||
reset();
|
reset(false);
|
||||||
|
|
||||||
QList<QWaylandInputDevice *> inputDevices = mDisplay->inputDevices();
|
QList<QWaylandInputDevice *> inputDevices = mDisplay->inputDevices();
|
||||||
for (int i = 0; i < inputDevices.size(); ++i)
|
for (int i = 0; i < inputDevices.size(); ++i)
|
||||||
@ -132,8 +132,11 @@ void QWaylandWindow::initWindow()
|
|||||||
if (window()->type() == Qt::Desktop)
|
if (window()->type() == Qt::Desktop)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!isInitialized())
|
if (!isInitialized()) {
|
||||||
initializeWlSurface();
|
initializeWlSurface();
|
||||||
|
QPlatformSurfaceEvent e(QPlatformSurfaceEvent::SurfaceCreated);
|
||||||
|
QGuiApplication::sendEvent(window(), &e);
|
||||||
|
}
|
||||||
|
|
||||||
if (shouldCreateSubSurface()) {
|
if (shouldCreateSubSurface()) {
|
||||||
Q_ASSERT(!mSubSurfaceWindow);
|
Q_ASSERT(!mSubSurfaceWindow);
|
||||||
@ -240,8 +243,12 @@ bool QWaylandWindow::shouldCreateSubSurface() const
|
|||||||
return QPlatformWindow::parent() != Q_NULLPTR;
|
return QPlatformWindow::parent() != Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWaylandWindow::reset()
|
void QWaylandWindow::reset(bool sendDestroyEvent)
|
||||||
{
|
{
|
||||||
|
if (isInitialized() && sendDestroyEvent) {
|
||||||
|
QPlatformSurfaceEvent e(QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed);
|
||||||
|
QGuiApplication::sendEvent(window(), &e);
|
||||||
|
}
|
||||||
delete mShellSurface;
|
delete mShellSurface;
|
||||||
mShellSurface = 0;
|
mShellSurface = 0;
|
||||||
delete mSubSurfaceWindow;
|
delete mSubSurfaceWindow;
|
||||||
|
@ -252,7 +252,7 @@ private:
|
|||||||
void initializeWlSurface();
|
void initializeWlSurface();
|
||||||
bool shouldCreateShellSurface() const;
|
bool shouldCreateShellSurface() const;
|
||||||
bool shouldCreateSubSurface() const;
|
bool shouldCreateSubSurface() const;
|
||||||
void reset();
|
void reset(bool sendDestroyEvent = true);
|
||||||
void sendExposeEvent(const QRect &rect);
|
void sendExposeEvent(const QRect &rect);
|
||||||
|
|
||||||
void handleMouseEventWithDecoration(QWaylandInputDevice *inputDevice, const QWaylandPointerEvent &e);
|
void handleMouseEventWithDecoration(QWaylandInputDevice *inputDevice, const QWaylandPointerEvent &e);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user