QWaylandSurfaceRole Class | Qt Wayland Compositor | Qt 6.10.3
Description: The QWaylandSurfaceRole class represents the role of the surface in context of wl_surface.

- Qt 6.10
- Qt Wayland Compositor
- C++ Classes
- QWaylandSurfaceRole
- Qt Wayland Compositor | Commercial or GPLv3

# 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`

- List of all members, including inherited members

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