本页内容

WaylandCompositor QML Type (Uncreatable)

管理 Wayland 显示服务器。更多...

Import Statement: import QtWayland.Compositor
In C++: QWaylandCompositor

注意:此类型无法创建。无法在 QML 中实例化。

属性

信号

方法

详细说明

WaylandCompositor 负责管理与客户端的连接,以及各种outputs 和seats 。

通常,一个合成器应用程序会拥有一个 WaylandCompositor 实例,该实例可以拥有多个作为子节点的输出。当客户端请求合成器创建一个表面时,该请求将由 onSurfaceRequested 处理程序处理。

合成器支持的扩展应被实例化,并添加到 extensions 属性中,或者直接作为 WaylandCompositor 的子节点。

属性文档

additionalShmFormats : list<enum> [since 6.0]

该属性存储了合成器声明支持的其他 wl_shm 格式的列表。

默认情况下,仅列出必需的 ShmFormat_ARGB8888 和 ShmFormat_XRGB8888,因此该列表为空。其他格式可能需要在内部进行转换,从而可能影响性能。

必须在合成器组件完成之前设置此属性。此后的更改将无效。

该属性自 Qt 6.0 起引入。

created : bool [read-only]

如果已初始化 `WaylandCompositor `,则该属性为真;否则为假。

defaultOutput : WaylandOutput

该属性包含添加到WaylandCompositor 的输出列表中的第一个项;如果尚未添加任何输出,则该属性值为null。

设置新的默认输出会将其追加到输出列表的开头,使其成为新的默认值,但之前的默认值不会从列表中移除。

defaultSeat : WaylandSeat [read-only]

此属性包含该WaylandCompositor 的默认座位。

extensions : list

合成器向其客户端发布的扩展列表。对于合成器应支持的任何 Wayland 扩展,都应实例化其组件,并将其添加到扩展列表中。不过,通常无需引用此属性,因为所有直接子项都会自动被分配到该属性中。

例如,以下代码将允许客户端通过xdg_shell 接口向合成器请求xdg_shell 绘图区域。

import QtWayland.Compositor
import QtWayland.Compositor.XdgShell

WaylandCompositor {
    XdgShell {
        // ...
    }
}

retainedSelection : bool [default: false]

该属性控制合成器是否保留剪贴板选定数据的副本。当true 时,合成器会立即读取并缓存来自所属客户端的所有剪贴板数据。这会带来性能开销。

socketName : string

该属性存储了WaylandCompositor 用于与客户端通信的套接字名称。必须在组件完成之前设置该属性。

如果 socketName 为空(默认值),则改用--wayland-socket-name 的 start 参数的内容。如果未设置该参数,组合器会尝试查找一个套接字名称,默认值为wayland-0 。

useHardwareIntegrationExtension : bool [default: true]

该属性用于指定是否应为该WaylandCompositor 启用硬件集成扩展。

必须在合成器组件完成之前设置此属性。

信号文档

void surfaceCreated(WaylandSurface surface)

当创建了一个新的WaylandSurface 实例surface 时,会发出此信号。

注意: 相应的处理程序 为onSurfaceCreated 。

void surfaceRequested(WaylandClient client, int id, int version)

当client 创建了ID为id 的表面时,会发出此信号。同时还提供了version 接口。

连接到此信号的槽可以在该槽的作用域内创建并初始化一个WaylandSurface 实例。否则,将创建一个默认表面。

注意: 对应的处理程序 为onSurfaceRequested 。

方法文档

void addSocketDescriptor(fd)

在文件描述符fd 上监听客户端连接,该描述符指向一个已绑定并处于监听状态的服务器套接字。

该方法不会获取文件描述符的所有权;如有需要,必须显式关闭该文件描述符。

注意:此 方法仅在 libwayland 1.10.0 或更高版本中可用。如果针对较早版本的 libwayland 运行时进行构建,此方法将不执行任何操作。

void destroyClient(client)

从合成器角度来看,通过与其断开连接来销毁给定的WaylandClient client 。

void destroyClientForSurface(surface)

从合成器角度来看,通过与该客户端断开连接,从而销毁所属的WaylandSurface surface 客户端。

© 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.