QWaylandCompositor Class
QWaylandCompositor 类管理着 Wayland 显示服务器。更多
Header: | #include <QWaylandCompositor> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS WaylandCompositor) target_link_libraries(mytarget PRIVATE Qt6::WaylandCompositor) |
qmake: | QT += waylandcompositor |
在 QML 中: | WaylandCompositor |
继承: | QWaylandObject |
属性
|
|
公共功能
QWaylandCompositor(QObject *parent = nullptr) | |
virtual | ~QWaylandCompositor() override |
void | addSocketDescriptor(int fd) |
QVector<QWaylandCompositor::ShmFormat> | additionalShmFormats() const |
virtual void | create() |
QWaylandOutput * | defaultOutput() const |
QWaylandSeat * | defaultSeat() const |
void | destroyClient(QWaylandClient *client) |
void | destroyClientForSurface(QWaylandSurface *surface) |
virtual void | grabSurface(QWaylandSurfaceGrabber *grabber, const QWaylandBufferRef &buffer) |
bool | isCreated() const |
QWaylandOutput * | outputFor(QWindow *window) const |
bool | retainedSelectionEnabled() const |
QWaylandSeat * | seatFor(QInputEvent *inputEvent) |
void | setAdditionalShmFormats(const QVector<QWaylandCompositor::ShmFormat> &additionalShmFormats) |
void | setDefaultOutput(QWaylandOutput *output) |
void | setRetainedSelectionEnabled(bool enabled) |
void | setSocketName(const QByteArray &name) |
void | setUseHardwareIntegrationExtension(bool use) |
QByteArray | socketName() const |
bool | useHardwareIntegrationExtension() const |
信号
void | additionalShmFormatsChanged() |
void | createdChanged() |
void | defaultOutputChanged() |
void | defaultSeatChanged(QWaylandSeat *newDevice, QWaylandSeat *oldDevice) |
void | retainedSelectionChanged(bool retainedSelection) |
void | socketNameChanged(const QByteArray &socketName) |
void | surfaceCreated(QWaylandSurface *surface) |
void | surfaceRequested(QWaylandClient *client, uint id, int version) |
void | useHardwareIntegrationExtensionChanged() |
详细说明
QWaylandCompositor 管理与客户端的连接,以及不同的outputs 和seats 。
通常,一个合成器应用程序会有一个WaylandCompositor 实例,该实例可以有多个输出作为子实例。
属性文档
[since 6.0]
additionalShmFormats : QVector<ShmFormat>
此属性包含合成器支持的其他 wl_shm 格式列表。
默认情况下,只列出所需的 ShmFormat_ARGB8888 和 ShmFormat_XRGB8888,此列表将为空。
该属性必须在合成器created 之前设置。随后的更改不会产生任何影响。
此属性在 Qt 6.0 中引入。
访问函数:
QVector<QWaylandCompositor::ShmFormat> | additionalShmFormats() const |
void | setAdditionalShmFormats(const QVector<QWaylandCompositor::ShmFormat> &additionalShmFormats) |
Notifier 信号:
void | additionalShmFormatsChanged() |
[read-only]
created : const bool
如果QWaylandCompositor 已初始化,则此属性为 true,否则为 false。
访问功能:
bool | isCreated() const |
Notifier 信号:
void | createdChanged() |
defaultOutput : QWaylandOutput*
该属性包含添加到QWaylandCompositor 的输出列表中的第一个输出,如果没有添加输出,则为空。
设置一个新的默认输出会将其加入输出列表,使其成为新的默认输出,但之前的默认输出不会从列表中移除。如果新的默认输出已在输出列表中,则会被移到列表的开头。
访问功能:
QWaylandOutput * | defaultOutput() const |
void | setDefaultOutput(QWaylandOutput *output) |
通知信号:
void | defaultOutputChanged() |
[read-only]
defaultSeat : QWaylandSeat* const
此属性包含此QWaylandCompositor 的默认席位。
访问功能:
QWaylandSeat * | defaultSeat() const |
通知者信号:
void | defaultSeatChanged(QWaylandSeat *newDevice, QWaylandSeat *oldDevice) |
retainedSelection : bool
此属性表示是否启用保留选择。
访问功能:
bool | retainedSelectionEnabled() const |
void | setRetainedSelectionEnabled(bool enabled) |
通知信号:
void | retainedSelectionChanged(bool retainedSelection) |
socketName : QByteArray
该属性包含QWaylandCompositor 与客户端通信时使用的套接字名称。该属性必须在QWaylandCompositor 之前设置created 。
如果 socketName 为空(默认值),则会使用起始参数--wayland-socket-name
的内容。如果未设置该参数,编译器会尝试查找套接字名称,默认为wayland-0
。
访问功能:
QByteArray | socketName() const |
void | setSocketName(const QByteArray &name) |
Notifier 信号:
void | socketNameChanged(const QByteArray &socketName) |
useHardwareIntegrationExtension : bool
此属性表示是否应为QWaylandCompositor 启用硬件集成扩展。
该属性必须在合成器created 之前设置。
访问功能:
bool | useHardwareIntegrationExtension() const |
void | setUseHardwareIntegrationExtension(bool use) |
Notifier 信号:
void | useHardwareIntegrationExtensionChanged() |
成员函数 文档
QWaylandCompositor::QWaylandCompositor(QObject *parent = nullptr)
使用给定的parent 构建 QWaylandCompositor。
[override virtual noexcept]
QWaylandCompositor::~QWaylandCompositor()
[invokable]
void QWaylandCompositor::addSocketDescriptor(int fd)
监听文件描述符fd 上的客户端连接,该文件描述符指的是已绑定并监听的服务器套接字。
不会获取文件描述符的所有权;如果需要,必须明确关闭文件描述符。
注意: 此方法仅适用于 libwayland 1.10.0 或更新版本。如果使用较早的 libwayland 运行时,则此方法无效。
注: 此函数可通过元对象系统和 QML 调用。请参见Q_INVOKABLE 。
[virtual]
void QWaylandCompositor::create()
初始化QWaylandCompositor 。如果在子类中重载此函数,请务必调用基类的实现。
[invokable]
void QWaylandCompositor::destroyClient(QWaylandClient *client)
销毁client 。
注: 可通过元对象系统和 QML 调用该函数。请参见Q_INVOKABLE 。
[invokable]
void QWaylandCompositor::destroyClientForSurface(QWaylandSurface *surface)
销毁surface 的客户端。
注: 可通过元对象系统和 QML 调用该函数。请参阅Q_INVOKABLE 。
[virtual]
void QWaylandCompositor::grabSurface(QWaylandSurfaceGrabber *grabber, const QWaylandBufferRef &buffer)
从给定的buffer 中抓取曲面内容。默认实现需要将 OpenGL 上下文绑定到当前线程才能工作。如果无法做到这一点,请在您的合成器子类中重新实现此函数,以实现自定义逻辑。默认实现只抓取共享内存和 OpenGL 缓冲区,请在合成器子类中重新实现此功能,以处理更多缓冲区类型。
注意: 不应手动调用此函数,而应使用QWaylandSurfaceGrabber (grabber)。
[invokable]
QWaylandOutput *QWaylandCompositor::outputFor(QWindow *window) const
返回与给定window 相连的QWaylandOutput 。
注: 可通过元对象系统和 QML 调用此函数。请参见Q_INVOKABLE 。
QWaylandSeat *QWaylandCompositor::seatFor(QInputEvent *inputEvent)
为给定的输入事件选择席位inputEvent 。目前,Qt 只支持单个座位。
[signal]
void QWaylandCompositor::surfaceCreated(QWaylandSurface *surface)
当创建了一个新的QWaylandSurface 实例surface 时,就会发出这个信号。
[signal]
void QWaylandCompositor::surfaceRequested(QWaylandClient *client, uint id, int version)
当client 创建了一个 ID 为id 的曲面时,就会发出该信号。接口version 也可用。
连接此信号的槽可以在槽的范围内创建并初始化一个QWaylandSurface 实例。否则,将创建一个默认曲面。
与此信号的连接必须是Qt::DirectConnection 连接类型。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.