QWaylandCompositor Class
QWaylandCompositor 类负责管理 Wayland 显示服务器。更多内容...
| 标题: | #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) |
通知器信号:
| void | additionalShmFormatsChanged() |
[read-only] created : bool
如果已初始化 `QWaylandCompositor `,则该属性为真;否则为假。
访问函数:
| bool | isCreated() const |
通知器信号:
| void | createdChanged() |
defaultOutput : QWaylandOutput*
该属性包含已添加到QWaylandCompositor 的输出列表中的第一个项;如果尚未添加任何输出,则该属性值为null。
设置新的默认输出会将其追加到输出列表的开头,使其成为新的默认值,但之前的默认值不会从列表中移除。如果新的默认输出已经在输出列表中,则将其移至列表开头。
访问函数:
| QWaylandOutput * | defaultOutput() const |
| void | setDefaultOutput(QWaylandOutput *output) |
通知器信号:
| void | defaultOutputChanged() |
[read-only] defaultSeat : QWaylandSeat*
该属性包含此QWaylandCompositor 的默认席位。
访问函数:
| QWaylandSeat * | defaultSeat() const |
通知信号:
| void | defaultSeatChanged(QWaylandSeat *newDevice, QWaylandSeat *oldDevice) |
retainedSelection : bool
该属性控制合成器是否保留剪贴板选定数据的副本。当true 时,合成器会立即读取并缓存来自所属客户端的所有剪贴板数据。这会带来性能开销。默认值为false 。
访问函数:
| bool | retainedSelectionEnabled() const |
| void | setRetainedSelectionEnabled(bool enabled) |
通知器信号:
| void | retainedSelectionChanged(bool retainedSelection) |
另请参阅 QWaylandCompositor ::retainedSelectionReceived() 和QWaylandSurface::updateSelection()。
socketName : QByteArray
该属性存储QWaylandCompositor 用于与客户端通信的套接字名称。必须在QWaylandCompositor 被设置为created 之前设置此属性。
如果 socketName 为空(默认值),则改用--wayland-socket-name 参数中的内容。如果该参数未设置,合成器会尝试查找一个套接字名称,默认值为wayland-0 。
访问函数:
| QByteArray | socketName() const |
| void | setSocketName(const QByteArray &name) |
通知器信号:
| void | socketNameChanged(const QByteArray &socketName) |
useHardwareIntegrationExtension : bool
该属性用于指定是否应为该QWaylandCompositor 启用硬件集成扩展。
必须在合成器处于created 状态之前设置此属性。
访问函数:
| bool | useHardwareIntegrationExtension() const |
| void | setUseHardwareIntegrationExtension(bool use) |
通知信号:
| 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 连接类型。
© 2026 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.