diff options
Diffstat (limited to 'src')
43 files changed, 221 insertions, 94 deletions
diff --git a/src/client/global/qwaylandclientextension.h b/src/client/global/qwaylandclientextension.h index 37debc513..98272e571 100644 --- a/src/client/global/qwaylandclientextension.h +++ b/src/client/global/qwaylandclientextension.h @@ -95,7 +95,7 @@ public: return T::interface(); } - void bind(struct ::wl_registry *registry, int id, int ver) + void bind(struct ::wl_registry *registry, int id, int ver) override { T* instance = static_cast<T *>(this); // Make sure lowest version is used of the supplied version from the diff --git a/src/client/hardwareintegration/qwaylandclientbufferintegration_p.h b/src/client/hardwareintegration/qwaylandclientbufferintegration_p.h index f1f0cf932..7776c6158 100644 --- a/src/client/hardwareintegration/qwaylandclientbufferintegration_p.h +++ b/src/client/hardwareintegration/qwaylandclientbufferintegration_p.h @@ -86,8 +86,8 @@ public: EglConfig, EglContext }; - virtual void *nativeResource(NativeResource /*resource*/) { return Q_NULLPTR; } - virtual void *nativeResourceForContext(NativeResource /*resource*/, QPlatformOpenGLContext */*context*/) { return Q_NULLPTR; } + virtual void *nativeResource(NativeResource /*resource*/) { return nullptr; } + virtual void *nativeResourceForContext(NativeResource /*resource*/, QPlatformOpenGLContext */*context*/) { return nullptr; } }; } diff --git a/src/client/inputdeviceintegration/qwaylandinputdeviceintegrationfactory.cpp b/src/client/inputdeviceintegration/qwaylandinputdeviceintegrationfactory.cpp index 94eca3262..8f573064e 100644 --- a/src/client/inputdeviceintegration/qwaylandinputdeviceintegrationfactory.cpp +++ b/src/client/inputdeviceintegration/qwaylandinputdeviceintegrationfactory.cpp @@ -90,7 +90,7 @@ QWaylandInputDeviceIntegration *QWaylandInputDeviceIntegrationFactory::create(co if (QWaylandInputDeviceIntegration *ret = qLoadPlugin<QWaylandInputDeviceIntegration, QWaylandInputDeviceIntegrationPlugin>(loader(), name, args)) return ret; #endif - return Q_NULLPTR; + return nullptr; } } diff --git a/src/client/qwaylandcursor.cpp b/src/client/qwaylandcursor.cpp index 7caa247e5..bd820e28e 100644 --- a/src/client/qwaylandcursor.cpp +++ b/src/client/qwaylandcursor.cpp @@ -92,7 +92,7 @@ struct wl_cursor_image *QWaylandCursor::cursorImage(Qt::CursorShape newShape) waylandCursor = requestCursor((WaylandCursor)newShape); } else if (newShape == Qt::BitmapCursor) { // cannot create a wl_cursor_image for a CursorShape - return Q_NULLPTR; + return nullptr; } else { //TODO: Custom cursor logic (for resize arrows) } @@ -119,7 +119,7 @@ QSharedPointer<QWaylandBuffer> QWaylandCursor::cursorBitmapImage(const QCursor * const QImage &img = cursor->pixmap().toImage(); QSharedPointer<QWaylandShmBuffer> buffer(new QWaylandShmBuffer(mDisplay, img.size(), img.format())); - memcpy(buffer->image()->bits(), img.bits(), img.byteCount()); + memcpy(buffer->image()->bits(), img.bits(), img.sizeInBytes()); return buffer; } diff --git a/src/client/qwaylanddatadevice.cpp b/src/client/qwaylanddatadevice.cpp index 33068c5e9..66f36f75b 100644 --- a/src/client/qwaylanddatadevice.cpp +++ b/src/client/qwaylanddatadevice.cpp @@ -97,7 +97,7 @@ void QWaylandDataDevice::setSelectionSource(QWaylandDataSource *source) { if (source) connect(source, &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::selectionSourceCancelled); - set_selection(source ? source->object() : Q_NULLPTR, m_inputDevice->serial()); + set_selection(source ? source->object() : nullptr, m_inputDevice->serial()); m_selectionSource.reset(source); } @@ -160,7 +160,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface, m_dragWindow = QWaylandWindow::fromWlSurface(surface)->window(); m_dragPoint = calculateDragPosition(x, y, m_dragWindow); - QMimeData *dragData = Q_NULLPTR; + QMimeData *dragData = nullptr; Qt::DropActions supportedActions; m_dragOffer.reset(static_cast<QWaylandDataOffer *>(wl_data_offer_get_user_data(id))); diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp index 86cfe1a0d..b2372f088 100644 --- a/src/client/qwaylanddisplay.cpp +++ b/src/client/qwaylanddisplay.cpp @@ -136,8 +136,8 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration) , mLastInputSerial(0) , mLastInputDevice(0) , mLastInputWindow(0) - , mLastKeyboardFocus(Q_NULLPTR) - , mSyncCallback(Q_NULLPTR) + , mLastKeyboardFocus(nullptr) + , mSyncCallback(nullptr) { qRegisterMetaType<uint32_t>("uint32_t"); @@ -446,7 +446,7 @@ void QWaylandDisplay::handleWaylandSync() // This callback is used to set the window activation because we may get an activate/deactivate // pair, and the latter one would be lost in the QWindowSystemInterface queue, if we issue the // handleWindowActivated() calls immediately. - QWindow *activeWindow = mActiveWindows.empty() ? Q_NULLPTR : mActiveWindows.last()->window(); + QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window(); if (activeWindow != QGuiApplication::focusWindow()) QWindowSystemInterface::handleWindowActivated(activeWindow); } @@ -456,7 +456,7 @@ const wl_callback_listener QWaylandDisplay::syncCallbackListener = { Q_UNUSED(time); wl_callback_destroy(callback); QWaylandDisplay *display = static_cast<QWaylandDisplay *>(data); - display->mSyncCallback = Q_NULLPTR; + display->mSyncCallback = nullptr; display->handleWaylandSync(); } }; diff --git a/src/client/qwaylandintegration.cpp b/src/client/qwaylandintegration.cpp index bffadf29a..34845c639 100644 --- a/src/client/qwaylandintegration.cpp +++ b/src/client/qwaylandintegration.cpp @@ -122,7 +122,7 @@ public: QWaylandIntegration::QWaylandIntegration() : mClientBufferIntegration(0) - , mInputDeviceIntegration(Q_NULLPTR) + , mInputDeviceIntegration(nullptr) , mFontDb(new QGenericUnixFontDatabase()) , mNativeInterface(new QWaylandNativeInterface(this)) #if QT_CONFIG(accessibility) diff --git a/src/client/qwaylandscreen.cpp b/src/client/qwaylandscreen.cpp index 5b43428d9..b6336f2e6 100644 --- a/src/client/qwaylandscreen.cpp +++ b/src/client/qwaylandscreen.cpp @@ -147,7 +147,7 @@ void QWaylandScreen::setOrientationUpdateMask(Qt::ScreenOrientations mask) { foreach (QWindow *window, QGuiApplication::allWindows()) { QWaylandWindow *w = static_cast<QWaylandWindow *>(window->handle()); - if (w && w->screen() == this) + if (w && w->waylandScreen() == this) w->setOrientationMask(mask); } } diff --git a/src/client/qwaylandshmbackingstore.cpp b/src/client/qwaylandshmbackingstore.cpp index 2085bc597..a9883c5c6 100644 --- a/src/client/qwaylandshmbackingstore.cpp +++ b/src/client/qwaylandshmbackingstore.cpp @@ -125,7 +125,7 @@ QWaylandShmBuffer::~QWaylandShmBuffer(void) { delete mMarginsImage; if (mImage.constBits()) - munmap((void *) mImage.constBits(), mImage.byteCount()); + munmap((void *) mImage.constBits(), mImage.sizeInBytes()); if (mShmPool) wl_shm_pool_destroy(mShmPool); } @@ -171,7 +171,7 @@ QWaylandShmBackingStore::QWaylandShmBackingStore(QWindow *window) QWaylandShmBackingStore::~QWaylandShmBackingStore() { if (QWaylandWindow *w = waylandWindow()) - w->setBackingStore(Q_NULLPTR); + w->setBackingStore(nullptr); // if (mFrontBuffer == waylandWindow()->attached()) // waylandWindow()->attach(0); @@ -287,10 +287,10 @@ void QWaylandShmBackingStore::resize(const QSize &size) buffer = getBuffer(sizeWithMargins); } - int oldSize = mBackBuffer ? mBackBuffer->image()->byteCount() : 0; + qssize_t oldSize = mBackBuffer ? mBackBuffer->image()->sizeInBytes() : 0; // mBackBuffer may have been deleted here but if so it means its size was different so we wouldn't copy it anyway - if (mBackBuffer != buffer && oldSize == buffer->image()->byteCount()) { - memcpy(buffer->image()->bits(), mBackBuffer->image()->constBits(), buffer->image()->byteCount()); + if (mBackBuffer != buffer && oldSize == buffer->image()->sizeInBytes()) { + memcpy(buffer->image()->bits(), mBackBuffer->image()->constBits(), buffer->image()->sizeInBytes()); } mBackBuffer = buffer; // ensure the new buffer is at the beginning of the list so next time getBuffer() will pick diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index cff380e8f..48f0d213a 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -80,7 +80,7 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = 0; QWaylandWindow::QWaylandWindow(QWindow *window) : QObject() , QPlatformWindow(window) - , mDisplay(screen()->display()) + , mDisplay(waylandScreen()->display()) , mShellSurface(0) , mSubSurfaceWindow(0) , mWindowDecoration(0) @@ -95,7 +95,7 @@ QWaylandWindow::QWaylandWindow(QWindow *window) , mScale(1) , mState(Qt::WindowNoState) , mMask() - , mBackingStore(Q_NULLPTR) + , mBackingStore(nullptr) , mUpdateRequested(false) { static WId id = 1; @@ -194,7 +194,7 @@ void QWaylandWindow::initWindow() } } - mScale = screen()->scale(); + mScale = waylandScreen()->scale(); // Enable high-dpi rendering. Scale() returns the screen scale factor and will // typically be integer 1 (normal-dpi) or 2 (high-dpi). Call set_buffer_scale() @@ -241,7 +241,7 @@ bool QWaylandWindow::shouldCreateShellSurface() const bool QWaylandWindow::shouldCreateSubSurface() const { - return QPlatformWindow::parent() != Q_NULLPTR; + return QPlatformWindow::parent() != nullptr; } void QWaylandWindow::reset(bool sendDestroyEvent) @@ -369,7 +369,7 @@ void QWaylandWindow::closePopups(QWaylandWindow *parent) QWaylandScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const { - return mScreens.isEmpty() ? screen() : mScreens.first(); + return mScreens.isEmpty() ? waylandScreen() : mScreens.first(); } void QWaylandWindow::setVisible(bool visible) @@ -603,6 +603,7 @@ const wl_callback_listener QWaylandWindow::callbackListener = { void QWaylandWindow::frameCallback(void *data, struct wl_callback *callback, uint32_t time) { Q_UNUSED(time); + Q_UNUSED(callback); QWaylandWindow *self = static_cast<QWaylandWindow*>(data); self->mWaitingForFrameSync = false; @@ -642,7 +643,7 @@ QWaylandSubSurface *QWaylandWindow::subSurfaceWindow() const return mSubSurfaceWindow; } -QWaylandScreen *QWaylandWindow::screen() const +QWaylandScreen *QWaylandWindow::waylandScreen() const { return static_cast<QWaylandScreen *>(QPlatformWindow::screen()); } @@ -916,7 +917,7 @@ void QWaylandWindow::handleMouseEventWithDecoration(QWaylandInputDevice *inputDe #if QT_CONFIG(cursor) void QWaylandWindow::setMouseCursor(QWaylandInputDevice *device, const QCursor &cursor) { - device->setCursor(cursor, screen()); + device->setCursor(cursor, waylandScreen()); } void QWaylandWindow::restoreMouseCursor(QWaylandInputDevice *device) diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h index 961b7881d..4cebcd7af 100644 --- a/src/client/qwaylandwindow_p.h +++ b/src/client/qwaylandwindow_p.h @@ -142,7 +142,7 @@ public: QWaylandDisplay *display() const { return mDisplay; } QWaylandShellSurface *shellSurface() const; QWaylandSubSurface *subSurfaceWindow() const; - QWaylandScreen *screen() const; + QWaylandScreen *waylandScreen() const; void handleContentOrientationChange(Qt::ScreenOrientation orientation) override; void setOrientationMask(Qt::ScreenOrientations mask); diff --git a/src/client/qwaylandwlshellintegration.cpp b/src/client/qwaylandwlshellintegration.cpp index e945745e2..e51637108 100644 --- a/src/client/qwaylandwlshellintegration.cpp +++ b/src/client/qwaylandwlshellintegration.cpp @@ -55,7 +55,7 @@ QWaylandWlShellIntegration *QWaylandWlShellIntegration::create(QWaylandDisplay * } QWaylandWlShellIntegration::QWaylandWlShellIntegration(QWaylandDisplay *display) - : m_wlShell(Q_NULLPTR) + : m_wlShell(nullptr) { Q_FOREACH (QWaylandDisplay::RegistryGlobal global, display->globals()) { if (global.interface == QLatin1String("wl_shell")) { diff --git a/src/client/qwaylandwlshellsurface.cpp b/src/client/qwaylandwlshellsurface.cpp index 92223f45e..cd10958d9 100644 --- a/src/client/qwaylandwlshellsurface.cpp +++ b/src/client/qwaylandwlshellsurface.cpp @@ -58,7 +58,7 @@ QWaylandWlShellSurface::QWaylandWlShellSurface(struct ::wl_shell_surface *shell_ , m_window(window) , m_maximized(false) , m_fullscreen(false) - , m_extendedWindow(Q_NULLPTR) + , m_extendedWindow(nullptr) { if (window->display()->windowExtension()) m_extendedWindow = new QWaylandExtendedSurface(window); diff --git a/src/client/qwaylandxdgshellintegration.cpp b/src/client/qwaylandxdgshellintegration.cpp index 04b8e8048..7c40d2dd7 100644 --- a/src/client/qwaylandxdgshellintegration.cpp +++ b/src/client/qwaylandxdgshellintegration.cpp @@ -57,7 +57,7 @@ QWaylandXdgShellIntegration *QWaylandXdgShellIntegration::create(QWaylandDisplay } QWaylandXdgShellIntegration::QWaylandXdgShellIntegration(QWaylandDisplay *display) - : m_xdgShell(Q_NULLPTR) + : m_xdgShell(nullptr) { Q_FOREACH (QWaylandDisplay::RegistryGlobal global, display->globals()) { if (global.interface == QLatin1String("xdg_shell")) { diff --git a/src/client/qwaylandxdgsurface.cpp b/src/client/qwaylandxdgsurface.cpp index fe8761e5b..60266af68 100644 --- a/src/client/qwaylandxdgsurface.cpp +++ b/src/client/qwaylandxdgsurface.cpp @@ -61,7 +61,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, QWaylandWindow * , m_minimized(false) , m_fullscreen(false) , m_active(false) - , m_extendedWindow(Q_NULLPTR) + , m_extendedWindow(nullptr) { if (window->display()->windowExtension()) m_extendedWindow = new QWaylandExtendedSurface(window); @@ -105,7 +105,7 @@ void QWaylandXdgSurface::setMaximized() void QWaylandXdgSurface::setFullscreen() { if (!m_fullscreen) - set_fullscreen(Q_NULLPTR); + set_fullscreen(nullptr); } void QWaylandXdgSurface::setNormal() diff --git a/src/client/shellintegration/qwaylandshellintegrationfactory.cpp b/src/client/shellintegration/qwaylandshellintegrationfactory.cpp index 09c62339b..c5a505bbe 100644 --- a/src/client/shellintegration/qwaylandshellintegrationfactory.cpp +++ b/src/client/shellintegration/qwaylandshellintegrationfactory.cpp @@ -90,7 +90,7 @@ QWaylandShellIntegration *QWaylandShellIntegrationFactory::create(const QString if (QWaylandShellIntegration *ret = qLoadPlugin<QWaylandShellIntegration, QWaylandShellIntegrationPlugin>(loader(), name, args)) return ret; #endif - return Q_NULLPTR; + return nullptr; } } diff --git a/src/compositor/compositor_api/qwaylandbufferref.cpp b/src/compositor/compositor_api/qwaylandbufferref.cpp index 57a120e48..8ceeeea56 100644 --- a/src/compositor/compositor_api/qwaylandbufferref.cpp +++ b/src/compositor/compositor_api/qwaylandbufferref.cpp @@ -185,7 +185,7 @@ bool QWaylandBufferRef::isDestroyed() const */ struct ::wl_resource *QWaylandBufferRef::wl_buffer() const { - return d->buffer ? d->buffer->waylandBufferHandle() : Q_NULLPTR; + return d->buffer ? d->buffer->waylandBufferHandle() : nullptr; } /*! diff --git a/src/compositor/compositor_api/qwaylandclient.cpp b/src/compositor/compositor_api/qwaylandclient.cpp index f6b5564b8..cdabb6a91 100644 --- a/src/compositor/compositor_api/qwaylandclient.cpp +++ b/src/compositor/compositor_api/qwaylandclient.cpp @@ -146,7 +146,7 @@ QWaylandClient *QWaylandClient::fromWlClient(QWaylandCompositor *compositor, wl_ if (!wlClient) return 0; - QWaylandClient *client = Q_NULLPTR; + QWaylandClient *client = nullptr; wl_listener *l = wl_client_get_destroy_listener(wlClient, QWaylandClientPrivate::client_destroy_callback); diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp index 00f3d83f0..de6a9c8e7 100644 --- a/src/compositor/compositor_api/qwaylandcompositor.cpp +++ b/src/compositor/compositor_api/qwaylandcompositor.cpp @@ -656,7 +656,7 @@ QWaylandOutput *QWaylandCompositor::outputFor(QWindow *window) const return output; } - return Q_NULLPTR; + return nullptr; } /*! @@ -822,7 +822,7 @@ QWaylandSeat *QWaylandCompositor::defaultSeat() const Q_D(const QWaylandCompositor); if (d->seats.size()) return d->seats.first(); - return Q_NULLPTR; + return nullptr; } /*! diff --git a/src/compositor/compositor_api/qwaylandcompositor_p.h b/src/compositor/compositor_api/qwaylandcompositor_p.h index 3970ff152..18595a806 100644 --- a/src/compositor/compositor_api/qwaylandcompositor_p.h +++ b/src/compositor/compositor_api/qwaylandcompositor_p.h @@ -87,7 +87,7 @@ public: void destroySurface(QWaylandSurface *surface); void unregisterSurface(QWaylandSurface *surface); - QWaylandOutput *defaultOutput() const { return outputs.size() ? outputs.first() : Q_NULLPTR; } + QWaylandOutput *defaultOutput() const { return outputs.size() ? outputs.first() : nullptr; } inline QtWayland::ClientBufferIntegration *clientBufferIntegration() const; inline QtWayland::ServerBufferIntegration *serverBufferIntegration() const; diff --git a/src/compositor/compositor_api/qwaylandkeyboard.cpp b/src/compositor/compositor_api/qwaylandkeyboard.cpp index c30f7b18d..930eae1ae 100644 --- a/src/compositor/compositor_api/qwaylandkeyboard.cpp +++ b/src/compositor/compositor_api/qwaylandkeyboard.cpp @@ -122,7 +122,7 @@ void QWaylandKeyboardPrivate::sendEnter(QWaylandSurface *surface, Resource *keyb void QWaylandKeyboardPrivate::focused(QWaylandSurface *surface) { if (surface && surface->isCursorSurface()) - surface = Q_NULLPTR; + surface = nullptr; if (focus != surface) { if (focusResource) { uint32_t serial = compositor()->nextSerial(); @@ -466,7 +466,7 @@ QWaylandClient *QWaylandKeyboard::focusClient() const { Q_D(const QWaylandKeyboard); if (!d->focusResource) - return Q_NULLPTR; + return nullptr; return QWaylandClient::fromWlClient(compositor(), d->focusResource->client()); } diff --git a/src/compositor/compositor_api/qwaylandoutput.cpp b/src/compositor/compositor_api/qwaylandoutput.cpp index 522de08e8..70f87e335 100644 --- a/src/compositor/compositor_api/qwaylandoutput.cpp +++ b/src/compositor/compositor_api/qwaylandoutput.cpp @@ -104,8 +104,8 @@ static QtWaylandServer::wl_output::transform toWlTransform(const QWaylandOutput: QWaylandOutputPrivate::QWaylandOutputPrivate() : QtWaylandServer::wl_output() - , compositor(Q_NULLPTR) - , window(Q_NULLPTR) + , compositor(nullptr) + , window(nullptr) , currentMode(-1) , preferredMode(-1) , subpixel(QWaylandOutput::SubpixelUnknown) @@ -319,7 +319,7 @@ struct ::wl_resource *QWaylandOutput::resourceForClient(QWaylandClient *client) if (r) return r->handle; - return Q_NULLPTR; + return nullptr; } /*! @@ -989,7 +989,7 @@ void QWaylandOutput::handleSetHeight(int newHeight) void QWaylandOutput::handleWindowDestroyed() { Q_D(QWaylandOutput); - d->window = Q_NULLPTR; + d->window = nullptr; emit windowChanged(); emit windowDestroyed(); } diff --git a/src/compositor/compositor_api/qwaylandoutput_p.h b/src/compositor/compositor_api/qwaylandoutput_p.h index 594fe1291..dab6daf73 100644 --- a/src/compositor/compositor_api/qwaylandoutput_p.h +++ b/src/compositor/compositor_api/qwaylandoutput_p.h @@ -87,7 +87,7 @@ struct QWaylandSurfaceViewMapper if (surface && surface->primaryView() == views.at(i)) return views.at(i); } - return Q_NULLPTR; + return nullptr; } QWaylandSurface *surface; diff --git a/src/compositor/compositor_api/qwaylandpointer.cpp b/src/compositor/compositor_api/qwaylandpointer.cpp index bf4bf547d..4bdee9be2 100644 --- a/src/compositor/compositor_api/qwaylandpointer.cpp +++ b/src/compositor/compositor_api/qwaylandpointer.cpp @@ -133,7 +133,7 @@ void QWaylandPointerPrivate::pointer_set_cursor(wl_pointer::Resource *resource, Q_UNUSED(serial); if (!surface) { - seat->cursorSurfaceRequest(Q_NULLPTR, 0, 0); + seat->cursorSurfaceRequest(nullptr, 0, 0); return; } @@ -250,7 +250,7 @@ void QWaylandPointer::sendMouseMoveEvent(QWaylandView *view, const QPointF &loca { Q_D(QWaylandPointer); if (view && (!view->surface() || view->surface()->isCursorSurface())) - view = Q_NULLPTR; + view = nullptr; d->seat->setMouseFocus(view); d->localPosition = localPos; d->spacePosition = outputSpacePos; diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp index a993467ac..85c8bc2dd 100644 --- a/src/compositor/compositor_api/qwaylandquickitem.cpp +++ b/src/compositor/compositor_api/qwaylandquickitem.cpp @@ -384,7 +384,7 @@ QWaylandQuickItem::~QWaylandQuickItem() QWaylandCompositor *QWaylandQuickItem::compositor() const { Q_D(const QWaylandQuickItem); - return d->view->surface() ? d->view->surface()->compositor() : Q_NULLPTR; + return d->view->surface() ? d->view->surface()->compositor() : nullptr; } /*! @@ -595,7 +595,7 @@ void QWaylandQuickItem::hoverLeaveEvent(QHoverEvent *event) Q_D(QWaylandQuickItem); if (d->shouldSendInputEvents()) { QWaylandSeat *seat = compositor()->seatFor(event); - seat->setMouseFocus(Q_NULLPTR); + seat->setMouseFocus(nullptr); } else { event->ignore(); } @@ -957,9 +957,14 @@ void QWaylandQuickItem::parentChanged(QWaylandSurface *newParent, QWaylandSurfac void QWaylandQuickItem::updateSize() { Q_D(QWaylandQuickItem); - if (d->sizeFollowsSurface && surface()) { - setSize(surface()->size() * (d->scaleFactor() / surface()->bufferScale())); - } + + QSize size(0, 0); + if (surface()) + size = surface()->size() * (d->scaleFactor() / surface()->bufferScale()); + + setImplicitSize(size.width(), size.height()); + if (d->sizeFollowsSurface) + setSize(size); } /*! @@ -1040,6 +1045,9 @@ bool QWaylandQuickItem::sizeFollowsSurface() const return d->sizeFollowsSurface; } +//TODO: sizeFollowsSurface became obsolete when we added an implementation for +//implicit size. The property is here for compatibility reasons only and should +//be removed or at least default to false in Qt 6. void QWaylandQuickItem::setSizeFollowsSurface(bool sizeFollowsSurface) { Q_D(QWaylandQuickItem); diff --git a/src/compositor/compositor_api/qwaylandquickitem_p.h b/src/compositor/compositor_api/qwaylandquickitem_p.h index 30b96c4f6..98af6ba7c 100644 --- a/src/compositor/compositor_api/qwaylandquickitem_p.h +++ b/src/compositor/compositor_api/qwaylandquickitem_p.h @@ -109,9 +109,9 @@ class QWaylandQuickItemPrivate : public QQuickItemPrivate public: QWaylandQuickItemPrivate() : QQuickItemPrivate() - , view(Q_NULLPTR) - , oldSurface(Q_NULLPTR) - , provider(Q_NULLPTR) + , view(nullptr) + , oldSurface(nullptr) + , provider(nullptr) , paintEnabled(true) , touchEventsEnabled(true) , inputEventsEnabled(true) @@ -119,7 +119,7 @@ public: , newTexture(false) , focusOnClick(true) , sizeFollowsSurface(true) - , connectedWindow(Q_NULLPTR) + , connectedWindow(nullptr) , origin(QWaylandSurface::OriginTopLeft) { } diff --git a/src/compositor/compositor_api/qwaylandseat.cpp b/src/compositor/compositor_api/qwaylandseat.cpp index b4b45392c..4b506bcda 100644 --- a/src/compositor/compositor_api/qwaylandseat.cpp +++ b/src/compositor/compositor_api/qwaylandseat.cpp @@ -65,7 +65,7 @@ QWaylandSeatPrivate::QWaylandSeatPrivate(QWaylandSeat *seat) , QtWaylandServer::wl_seat() , isInitialized(false) , compositor(nullptr) - , mouseFocus(Q_NULLPTR) + , mouseFocus(nullptr) , keyboardFocus(nullptr) , capabilities() #if QT_CONFIG(wayland_datadevice) @@ -298,7 +298,93 @@ uint QWaylandSeat::sendTouchPointEvent(QWaylandSurface *surface, int id, const Q } /*! - * Sends a frame event to the touch device of a \a client. + * \qmlmethod uint QtWaylandCompositor::WaylandSeat::sendTouchPointPressed(WaylandSurface surface, int id, point position) + * + * Sends a touch pressed event for the touch point \a id on \a surface with + * position \a position. + * + * \note You need to send a touch frame event when you are done sending touch + * events. + * + * Returns the serial for the touch down event. + */ + +/*! + * Sends a touch pressed event for the touch point \a id on \a surface with + * position \a position. + * + * \note You need to send a touch frame event when you are done sending touch + * events. + * + * Returns the serial for the touch down event. + */ +uint QWaylandSeat::sendTouchPointPressed(QWaylandSurface *surface, int id, const QPointF &position) +{ + return sendTouchPointEvent(surface, id, position, Qt::TouchPointPressed); +} + +/*! + * \qmlmethod void QtWaylandCompositor::WaylandSeat::sendTouchPointReleased(WaylandSurface surface, int id, point position) + * + * Sends a touch released event for the touch point \a id on \a surface with + * position \a position. + * + * \note You need to send a touch frame event when you are done sending touch + * events. + * + * Returns the serial for the touch up event. + */ + +/*! + * Sends a touch released event for the touch point \a id on \a surface with + * position \a position. + * + * \note You need to send a touch frame event when you are done sending touch + * events. + * + * Returns the serial for the touch up event. + */ +uint QWaylandSeat::sendTouchPointReleased(QWaylandSurface *surface, int id, const QPointF &position) +{ + return sendTouchPointEvent(surface, id, position, Qt::TouchPointReleased); +} + +/*! + * \qmlmethod void QtWaylandCompositor::WaylandSeat::sendTouchPointMoved(WaylandSurface surface, int id, point position) + * + * Sends a touch moved event for the touch point \a id on \a surface with + * position \a position. + * + * \note You need to send a touch frame event when you are done sending touch + * events. + * + * Returns the serial for the touch motion event. + */ + +/*! + * Sends a touch moved event for the touch point \a id on \a surface with + * position \a position. + * + * \note You need to send a touch frame event when you are done sending touch + * events. + * + * Returns the serial for the touch motion event. + */ +uint QWaylandSeat::sendTouchPointMoved(QWaylandSurface *surface, int id, const QPointF &position) +{ + return sendTouchPointEvent(surface, id, position, Qt::TouchPointMoved); +} + +/*! + * \qmlmethod void QtWaylandCompositor::WaylandSeat::sendTouchFrameEvent(WaylandClient client) + * + * Sends a frame event to the touch device of a \a client to indicate the end + * of a series of touch up, down, and motion events. + */ + +/*! + * Sends a frame event to the touch device of a \a client to indicate the end + * of a series of touch up, down, and motion events. */ void QWaylandSeat::sendTouchFrameEvent(QWaylandClient *client) { @@ -308,6 +394,12 @@ void QWaylandSeat::sendTouchFrameEvent(QWaylandClient *client) } /*! + * \qmlmethod void QtWaylandCompositor::WaylandSeat::sendTouchCancelEvent(WaylandClient client) + * + * Sends a cancel event to the touch device of a \a client. + */ + +/*! * Sends a cancel event to the touch device of a \a client. */ void QWaylandSeat::sendTouchCancelEvent(QWaylandClient *client) @@ -381,7 +473,7 @@ QWaylandSurface *QWaylandSeat::keyboardFocus() const { Q_D(const QWaylandSeat); if (d->keyboard.isNull() || !d->keyboard->focus()) - return Q_NULLPTR; + return nullptr; return d->keyboard->focus(); } diff --git a/src/compositor/compositor_api/qwaylandseat.h b/src/compositor/compositor_api/qwaylandseat.h index e5ef46dc6..d22e05a5b 100644 --- a/src/compositor/compositor_api/qwaylandseat.h +++ b/src/compositor/compositor_api/qwaylandseat.h @@ -99,8 +99,11 @@ public: void sendFullKeyEvent(QKeyEvent *event); uint sendTouchPointEvent(QWaylandSurface *surface, int id, const QPointF &point, Qt::TouchPointState state); - void sendTouchFrameEvent(QWaylandClient *client); - void sendTouchCancelEvent(QWaylandClient *client); + Q_INVOKABLE uint sendTouchPointPressed(QWaylandSurface *surface, int id, const QPointF &position); + Q_INVOKABLE uint sendTouchPointReleased(QWaylandSurface *surface, int id, const QPointF &position); + Q_INVOKABLE uint sendTouchPointMoved(QWaylandSurface *surface, int id, const QPointF &position); + Q_INVOKABLE void sendTouchFrameEvent(QWaylandClient *client); + Q_INVOKABLE void sendTouchCancelEvent(QWaylandClient *client); void sendFullTouchEvent(QWaylandSurface *surface, QTouchEvent *event); diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp index 945d68827..c817a7cda 100644 --- a/src/compositor/compositor_api/qwaylandsurface.cpp +++ b/src/compositor/compositor_api/qwaylandsurface.cpp @@ -127,9 +127,9 @@ QList<QWaylandSurfacePrivate *> QWaylandSurfacePrivate::uninitializedSurfaces; QWaylandSurfacePrivate::QWaylandSurfacePrivate() : QtWaylandServer::wl_surface() - , compositor(Q_NULLPTR) + , compositor(nullptr) , refCount(1) - , client(Q_NULLPTR) + , client(nullptr) , role(0) , inputRegion(infiniteRegion()) , bufferScale(1) @@ -139,7 +139,7 @@ QWaylandSurfacePrivate::QWaylandSurfacePrivate() , isInitialized(false) , contentOrientation(Qt::PrimaryOrientation) #if QT_CONFIG(im) - , inputMethodControl(Q_NULLPTR) + , inputMethodControl(nullptr) #endif , subsurface(0) { @@ -459,7 +459,7 @@ QWaylandClient *QWaylandSurface::client() const { Q_D(const QWaylandSurface); if (isDestroyed() || !compositor() || !compositor()->clients().contains(d->client)) - return Q_NULLPTR; + return nullptr; return d->client; } @@ -603,7 +603,7 @@ void QWaylandSurface::sendFrameCallbacks() int i = 0; while (i < d->frameCallbacks.size()) { if (d->frameCallbacks.at(i)->canSend) { - d->frameCallbacks.at(i)->surface = Q_NULLPTR; + d->frameCallbacks.at(i)->surface = nullptr; d->frameCallbacks.at(i)->send(time); d->frameCallbacks.removeAt(i); } else { @@ -716,7 +716,7 @@ QWaylandView *QWaylandSurface::primaryView() const { Q_D(const QWaylandSurface); if (d->views.isEmpty()) - return Q_NULLPTR; + return nullptr; return d->views.first(); } @@ -808,7 +808,7 @@ QWaylandSurfaceRole *QWaylandSurface::role() const QWaylandSurfacePrivate *QWaylandSurfacePrivate::get(QWaylandSurface *surface) { - return surface ? surface->d_func() : Q_NULLPTR; + return surface ? surface->d_func() : nullptr; } void QWaylandSurfacePrivate::ref() diff --git a/src/compositor/compositor_api/qwaylandsurfacegrabber.h b/src/compositor/compositor_api/qwaylandsurfacegrabber.h index ce1e397e5..c28614f37 100644 --- a/src/compositor/compositor_api/qwaylandsurfacegrabber.h +++ b/src/compositor/compositor_api/qwaylandsurfacegrabber.h @@ -60,7 +60,7 @@ public: RendererNotReady, }; Q_ENUM(Error) - explicit QWaylandSurfaceGrabber(QWaylandSurface *surface, QObject *parent = Q_NULLPTR); + explicit QWaylandSurfaceGrabber(QWaylandSurface *surface, QObject *parent = nullptr); QWaylandSurface *surface() const; void grab(); diff --git a/src/compositor/compositor_api/qwaylandview.cpp b/src/compositor/compositor_api/qwaylandview.cpp index 9e8297574..4d6f392e1 100644 --- a/src/compositor/compositor_api/qwaylandview.cpp +++ b/src/compositor/compositor_api/qwaylandview.cpp @@ -55,7 +55,7 @@ void QWaylandViewPrivate::markSurfaceAsDestroyed(QWaylandSurface *surface) Q_Q(QWaylandView); Q_ASSERT(surface == this->surface); - q->setSurface(Q_NULLPTR); + q->setSurface(nullptr); emit q->surfaceDestroyed(); } @@ -376,7 +376,7 @@ struct wl_resource *QWaylandView::surfaceResource() const { Q_D(const QWaylandView); if (!d->surface) - return Q_NULLPTR; + return nullptr; return d->surface->resource(); } diff --git a/src/compositor/compositor_api/qwaylandview_p.h b/src/compositor/compositor_api/qwaylandview_p.h index 326e0b297..a2bf219d7 100644 --- a/src/compositor/compositor_api/qwaylandview_p.h +++ b/src/compositor/compositor_api/qwaylandview_p.h @@ -69,9 +69,9 @@ public: static QWaylandViewPrivate *get(QWaylandView *view) { return view->d_func(); } QWaylandViewPrivate() - : renderObject(Q_NULLPTR) - , surface(Q_NULLPTR) - , output(Q_NULLPTR) + : renderObject(nullptr) + , surface(nullptr) + , output(nullptr) , nextBufferCommitted(false) , bufferLocked(false) , broadcastRequestedPositionChanged(false) diff --git a/src/compositor/extensions/qwaylandwlshell.cpp b/src/compositor/extensions/qwaylandwlshell.cpp index 96dbd3dc1..00a5a1272 100644 --- a/src/compositor/extensions/qwaylandwlshell.cpp +++ b/src/compositor/extensions/qwaylandwlshell.cpp @@ -104,8 +104,8 @@ void QWaylandWlShellPrivate::unregisterShellSurface(QWaylandWlShellSurface *shel QWaylandWlShellSurfacePrivate::QWaylandWlShellSurfacePrivate() : QWaylandCompositorExtensionPrivate() , wl_shell_surface() - , m_shell(Q_NULLPTR) - , m_surface(Q_NULLPTR) + , m_shell(nullptr) + , m_surface(nullptr) , m_windowType(Qt::WindowType::Window) { } @@ -195,7 +195,7 @@ void QWaylandWlShellSurfacePrivate::shell_surface_set_fullscreen(Resource *resou Q_Q(QWaylandWlShellSurface); QWaylandOutput *output = output_resource ? QWaylandOutput::fromResource(output_resource) - : Q_NULLPTR; + : nullptr; setWindowType(Qt::WindowType::Window); emit q->setFullScreen(QWaylandWlShellSurface::FullScreenMethod(method), framerate, output); } @@ -220,7 +220,7 @@ void QWaylandWlShellSurfacePrivate::shell_surface_set_maximized(Resource *resour Q_Q(QWaylandWlShellSurface); QWaylandOutput *output = output_resource ? QWaylandOutput::fromResource(output_resource) - : Q_NULLPTR; + : nullptr; setWindowType(Qt::WindowType::Window); emit q->setMaximized(output); } diff --git a/src/compositor/global/qwaylandcompositorextension.cpp b/src/compositor/global/qwaylandcompositorextension.cpp index 7b44dbde6..ee117bbae 100644 --- a/src/compositor/global/qwaylandcompositorextension.cpp +++ b/src/compositor/global/qwaylandcompositorextension.cpp @@ -146,7 +146,7 @@ QWaylandObject::QWaylandObject(QObjectPrivate &d, QObject *parent) QWaylandObject::~QWaylandObject() { foreach (QWaylandCompositorExtension *extension, extension_vector) - QWaylandCompositorExtensionPrivate::get(extension)->extension_container = Q_NULLPTR; + QWaylandCompositorExtensionPrivate::get(extension)->extension_container = nullptr; } QWaylandCompositorExtension *QWaylandObject::extension(const QByteArray &name) @@ -155,7 +155,7 @@ QWaylandCompositorExtension *QWaylandObject::extension(const QByteArray &name) if (extension_vector.at(i)->extensionInterface()->name == name) return extension_vector.at(i); } - return Q_NULLPTR; + return nullptr; } QWaylandCompositorExtension *QWaylandObject::extension(const wl_interface *interface) @@ -164,7 +164,7 @@ QWaylandCompositorExtension *QWaylandObject::extension(const wl_interface *inter if (extension_vector.at(i)->extensionInterface() == interface) return extension_vector.at(i); } - return Q_NULLPTR; + return nullptr; } QList<QWaylandCompositorExtension *> QWaylandObject::extensions() const diff --git a/src/compositor/global/qwaylandcompositorextension.h b/src/compositor/global/qwaylandcompositorextension.h index 73f8aab36..48fce0c96 100644 --- a/src/compositor/global/qwaylandcompositorextension.h +++ b/src/compositor/global/qwaylandcompositorextension.h @@ -114,7 +114,7 @@ public: static T *findIn(QWaylandObject *container) { - if (!container) return Q_NULLPTR; + if (!container) return nullptr; return qobject_cast<T *>(container->extension(T::interfaceName())); } diff --git a/src/compositor/global/qwaylandcompositorextension_p.h b/src/compositor/global/qwaylandcompositorextension_p.h index 56889cfab..68f817aa6 100644 --- a/src/compositor/global/qwaylandcompositorextension_p.h +++ b/src/compositor/global/qwaylandcompositorextension_p.h @@ -64,7 +64,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandCompositorExtensionPrivate : public QO public: QWaylandCompositorExtensionPrivate() : QObjectPrivate() - , extension_container(Q_NULLPTR) + , extension_container(nullptr) , initialized(false) { } diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp index 771b4b2e4..8a1009fa8 100644 --- a/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp +++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp @@ -162,7 +162,7 @@ void *QWaylandEglClientBufferIntegration::nativeResource(NativeResource resource default: break; } - return Q_NULLPTR; + return nullptr; } void *QWaylandEglClientBufferIntegration::nativeResourceForContext(NativeResource resource, QPlatformOpenGLContext *context) @@ -178,7 +178,7 @@ void *QWaylandEglClientBufferIntegration::nativeResourceForContext(NativeResourc default: break; } - return Q_NULLPTR; + return nullptr; } EGLDisplay QWaylandEglClientBufferIntegration::eglDisplay() const diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp index 2a9e39ed6..61cc9d468 100644 --- a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp +++ b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp @@ -327,7 +327,7 @@ void QWaylandGLContext::updateGLFormat() EGLSurface prevSurfaceDraw = eglGetCurrentSurface(EGL_DRAW); EGLSurface prevSurfaceRead = eglGetCurrentSurface(EGL_READ); - wl_surface *wlSurface = m_display->createSurface(Q_NULLPTR); + wl_surface *wlSurface = m_display->createSurface(nullptr); wl_egl_window *eglWindow = wl_egl_window_create(wlSurface, 1, 1); EGLSurface eglSurface = eglCreateWindowSurface(m_eglDisplay, m_config, eglWindow, 0); diff --git a/src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.cpp b/src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.cpp index 7a86785b0..de2288e51 100644 --- a/src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.cpp +++ b/src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.cpp @@ -70,7 +70,7 @@ ShmServerBuffer::ShmServerBuffer(ShmServerBufferIntegration *integration, const QString key = "qt_shm_emulation_" + QString::number(qimage.cacheKey()); m_shm = new QSharedMemory(key); - int shm_size = qimage.byteCount(); + qssize_t shm_size = qimage.sizeInBytes(); bool ok = m_shm->create(shm_size) && m_shm->lock(); if (ok) { memcpy(m_shm->data(), qimage.constBits(), shm_size); diff --git a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp index 453800c18..f39a7ce71 100644 --- a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp +++ b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp @@ -219,7 +219,7 @@ WaylandEglClientBufferIntegrationPrivate::WaylandEglClientBufferIntegrationPriva , egl_create_image(0) , egl_destroy_image(0) , gl_egl_image_target_texture_2d(0) - , funcs(Q_NULLPTR) + , funcs(nullptr) { } diff --git a/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp b/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp index 502b17c0d..fee812501 100644 --- a/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp +++ b/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp @@ -55,8 +55,8 @@ QT_BEGIN_NAMESPACE namespace QtWaylandClient { QWaylandIviShellIntegration::QWaylandIviShellIntegration() - : m_iviApplication(Q_NULLPTR) - , m_iviController(Q_NULLPTR) + : m_iviApplication(nullptr) + , m_iviController(nullptr) , m_lastSurfaceId(0) , m_surfaceNumber(0) , m_useEnvSurfaceId(false) @@ -129,11 +129,11 @@ uint32_t QWaylandIviShellIntegration::getNextUniqueSurfaceId() QWaylandShellSurface *QWaylandIviShellIntegration::createShellSurface(QWaylandWindow *window) { if (!m_iviApplication) - return Q_NULLPTR; + return nullptr; uint32_t surfaceId = getNextUniqueSurfaceId(); if (surfaceId == 0) - return Q_NULLPTR; + return nullptr; struct ivi_surface *surface = m_iviApplication->surface_create(surfaceId, window->object()); if (!m_iviController) diff --git a/src/plugins/shellintegration/ivi-shell/qwaylandivisurface.cpp b/src/plugins/shellintegration/ivi-shell/qwaylandivisurface.cpp index a16518cc3..335aa852c 100644 --- a/src/plugins/shellintegration/ivi-shell/qwaylandivisurface.cpp +++ b/src/plugins/shellintegration/ivi-shell/qwaylandivisurface.cpp @@ -52,7 +52,7 @@ QWaylandIviSurface::QWaylandIviSurface(struct ::ivi_surface *ivi_surface, QWayla : QtWayland::ivi_surface(ivi_surface) , QWaylandShellSurface(window) , m_window(window) - , m_extendedWindow(Q_NULLPTR) + , m_extendedWindow(nullptr) { createExtendedSurface(window); } @@ -63,7 +63,7 @@ QWaylandIviSurface::QWaylandIviSurface(struct ::ivi_surface *ivi_surface, QWayla , QWaylandShellSurface(window) , QtWayland::ivi_controller_surface(iviControllerSurface) , m_window(window) - , m_extendedWindow(Q_NULLPTR) + , m_extendedWindow(nullptr) { createExtendedSurface(window); } diff --git a/src/qtwaylandscanner/qtwaylandscanner.cpp b/src/qtwaylandscanner/qtwaylandscanner.cpp index ed36a1386..d6a83dbbc 100644 --- a/src/qtwaylandscanner/qtwaylandscanner.cpp +++ b/src/qtwaylandscanner/qtwaylandscanner.cpp @@ -504,6 +504,7 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr printf(" private:\n"); printf(" static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id);\n"); printf(" static void destroy_func(struct ::wl_resource *client_resource);\n"); + printf(" static void display_destroy_func(struct ::wl_listener *listener, void *data);\n"); printf("\n"); printf(" Resource *bind(struct ::wl_client *client, uint32_t id, int version);\n"); printf(" Resource *bind(struct ::wl_resource *handle);\n"); @@ -527,6 +528,10 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr printf(" Resource *m_resource;\n"); printf(" struct ::wl_global *m_global;\n"); printf(" uint32_t m_globalVersion;\n"); + printf(" struct DisplayDestroyedListener : ::wl_listener {\n"); + printf(" %s *parent;\n", interfaceName); + printf(" };\n"); + printf(" DisplayDestroyedListener m_displayDestroyedListener;\n"); printf(" };\n"); if (j < interfaces.size() - 1) @@ -607,6 +612,13 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr printf(" %s::~%s()\n", interfaceName, interfaceName); printf(" {\n"); + printf(" for (auto resource : qAsConst(m_resource_map))\n"); + printf(" wl_resource_set_implementation(resource->handle, nullptr, nullptr, nullptr);\n"); + printf("\n"); + printf(" if (m_global) {\n"); + printf(" wl_global_destroy(m_global);\n"); + printf(" wl_list_remove(&m_displayDestroyedListener.link);\n"); + printf(" }\n"); printf(" }\n"); printf("\n"); @@ -642,6 +654,9 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr printf(" {\n"); printf(" m_global = wl_global_create(display, &::%s_interface, version, this, bind_func);\n", interfaceName); printf(" m_globalVersion = version;\n"); + printf(" m_displayDestroyedListener.notify = %s::display_destroy_func;\n", interfaceName); + printf(" m_displayDestroyedListener.parent = this;\n"); + printf(" wl_display_add_destroy_listener(display, &m_displayDestroyedListener);\n"); printf(" }\n"); printf("\n"); @@ -674,6 +689,14 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr printf(" }\n"); printf("\n"); + printf(" void %s::display_destroy_func(struct ::wl_listener *listener, void *data)\n", interfaceName); + printf(" {\n"); + printf(" Q_UNUSED(data);\n"); + printf(" %s *that = static_cast<%s::DisplayDestroyedListener *>(listener)->parent;\n", interfaceName, interfaceName); + printf(" that->m_global = nullptr;\n"); + printf(" }\n"); + printf("\n"); + printf(" void %s::destroy_func(struct ::wl_resource *client_resource)\n", interfaceName); printf(" {\n"); printf(" Resource *resource = Resource::fromResource(client_resource);\n"); |