对于 qml 客户端,来自 C++ 的 QtWayland 注册失败

QtWayland registration from c++ fails for qml clients

我的 qtwayland 合成器测试有一个奇怪的问题。它似乎只适用于 qt c++ 客户端。 Qml 客户端以死锁结束,事件处理停止(对于客户端)。 我更改了此 https://doc.qt.io/archives/qt-5.11/qtwaylandcompositor-qwindow-compositor-example.html 示例并添加了以下功能:

void Compositor::onSurfaceCreated(QWaylandSurface *surface)
{
    connect(surface, &QWaylandSurface::subsurfacePositionChanged, this, &WaylandInterface::onSubsurfacePositionChanged);
    QQuickWindow *window = new QQuickWindow();
    window->resize( 400, 400);
    window->setVisible(true);
    QWaylandOutput* output = new QWaylandOutput( this, window );

    QCoreApplication::processEvents();
    View *view = new View(this);
    view->setSurface(surface);
    view->setOutput(output);
    view->m_window = window;
    m_views << view;

    connect(surface, &QWaylandSurface::surfaceDestroyed, view, [view] {
        view->m_window->requestUpdate();
    } );

    connect(surface, &QWaylandSurface::hasContentChanged, this, &WaylandInterface::surfaceHasContentChanged);
    connect(surface, &QWaylandSurface::hasContentChanged, view, [view] {
        view->m_window->requestUpdate();
    } );
    connect(surface, &QWaylandSurface::redraw, view, [view] {
        view->m_window->requestUpdate();
    } );


    QWaylandQuickItem * surfacItem = new QWaylandQuickItem( view->m_window->contentItem() );
    surfacItem->setSurface( surface );
    surfacItem->setOutput( view->output() );
    surfacItem->setPaintEnabled(true);
    surfacItem->setInputEventsEnabled(true);
    connect(surface, &QWaylandSurface::offsetForNextFrame, view, &View::onOffsetForNextFrame);
    connect(view, &QWaylandView::surfaceDestroyed, this, &WaylandInterface::viewSurfaceDestroyed);
}

对于 c++ 客户端,它创建一个 window 并将客户端嵌入其中,而 qml 客户端没有响应。创建 window、输出和 QuickItem 的顺序是否正确?我错过了什么吗?

谢谢, 凯恩

c++ 客户端使用单线程渲染,而 qml 客户端使用渲染线程。当一个暴露事件被发送到渲染器时,qtwayland 将阻止它,除非输出被命令释放互斥体。 renderer在锁住framebuffer的同时,在等待server,主线程在等待render thread => Deadlock。

回调可以通过 输出->frameStarted(); // 渲染前 输出->sendFrameCallbacks(); // 渲染后