QWaylandSurfaceRole Class

The QWaylandSurfaceRole class represents the role of the surface in context of wl_surface. More...

Header: #include <QWaylandSurfaceRole>
CMake: find_package(Qt6 REQUIRED COMPONENTS Waylandcompositor)
target_link_libraries(mytarget PRIVATE Qt6::Waylandcompositor)
qmake: QT += waylandcompositor
Since: Qt 5.8

Public Functions

QWaylandSurfaceRole(const QByteArray &name)
const QByteArray name()

Detailed Description

QWaylandSurfaceRole is used to represent the role of a QWaylandSurface. According to the protocol specification, the role of a surface is permanent once set, and if the same surface is later reused for a different role, this constitutes a protocol error. Setting the surface to the same role multiple times is not an error.

As an example, the QWaylandXdgShell can assign either "popup" or "toplevel" roles to surfaces. If get_toplevel is requested on a surface which has previously received a get_popup request, then the compositor will issue a protocol error.

Roles are compared by pointer value, so any two objects of QWaylandSurfaceRole will be considered different roles, regardless of what their names are. A typical way of assigning a role is to have a static QWaylandSurfaceRole object to represent it.

class MyShellSurfaceSubType
    static QWaylandSurfaceRole s_role;
    // ...

// ...

surface->setRole(&MyShellSurfaceSubType::s_role, resource->handle, MY_ERROR_CODE);

Member Function Documentation

QWaylandSurfaceRole::QWaylandSurfaceRole(const QByteArray &name)

Creates a QWaylandSurfaceRole and assigns it name. The name is used in error messages involving this QWaylandSurfaceRole.

const QByteArray QWaylandSurfaceRole::name()

Returns the name of the QWaylandSurfaceRole. The name is used in error messages involving this QWaylandSurfaceRole, for example if an attempt is made to change the role of a surface.

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