- Qt 6.8
- Qt Wayland Compositor
- C++ Classes
- QWaylandView
- Qt Wayland Compositor | Commercial or GPLv3

# QWaylandView Class

The QWaylandView class represents a view of a surface on an output. More...

Header: | #include <QWaylandView>
CMake: | find_package(Qt6 REQUIRED COMPONENTS WaylandCompositor) target_link_libraries(mytarget PRIVATE Qt6::WaylandCompositor)
qmake: | QT += waylandcompositor
Instantiated By: | WaylandView
Inherits: | QObject

- List of all members, including inherited members

## Properties

- allowDiscardFrontBuffer : bool
- bufferLocked : bool
- output : QWaylandOutput*
- surface : QWaylandSurface*

## Public Functions

| QWaylandView(QObject *renderObject = nullptr, QObject *parent = nullptr)
virtual | ~QWaylandView() override
virtual bool | advance()
bool | allowDiscardFrontBuffer() const
virtual void | bufferCommitted(const QWaylandBufferRef &buffer, const QRegion &damage)
virtual QWaylandBufferRef | currentBuffer()
virtual QRegion | currentDamage()
virtual void | discardCurrentBuffer()
bool | isBufferLocked() const
bool | isPrimary() const
QWaylandOutput * | output() const
void | setAllowDiscardFrontBuffer(bool discard)
void | setBufferLocked(bool locked)
void | setOutput(QWaylandOutput *output)
void | setPrimary()
void | setSurface(QWaylandSurface *surface)
QWaylandSurface * | surface() const
struct wl_resource * | surfaceResource() const

## Signals

void | allowDiscardFrontBufferChanged()
void | bufferLockedChanged()
void | outputChanged()
void | surfaceChanged()

## Detailed Description

The QWaylandView corresponds to the presentation of a surface on a specific output, managing the buffers that contain the contents to be rendered. You can have several views into the same surface.

## Property Documentation

### allowDiscardFrontBuffer : bool

By default, the view locks the current buffer until advance() is called. Set this property to `true` to allow Qt to release the buffer when the primary view is no longer using it.

This can be used to avoid the situation where a secondary view that updates on a lower frequency will throttle the frame rate of the client application.

Access functions:

bool | allowDiscardFrontBuffer() const
void | setAllowDiscardFrontBuffer(bool discard)

Notifier signal:

void | allowDiscardFrontBufferChanged()

### bufferLocked : bool

This property holds whether the view's buffer is currently locked. When the buffer is locked, advance() will not advance to the next buffer and returns `false`.

The default is `false`.

Access functions:

bool | isBufferLocked() const
void | setBufferLocked(bool locked)

Notifier signal:

void | bufferLockedChanged()

### output : QWaylandOutput*

This property holds the output on which this view displays its surface.

Access functions:

QWaylandOutput * | output() const
void | setOutput(QWaylandOutput *output)

Notifier signal:

void | outputChanged()

### surface : QWaylandSurface*

This property holds the surface viewed by this QWaylandView.

Access functions:

QWaylandSurface * | surface() const
void | setSurface(QWaylandSurface *surface)

Notifier signal:

void | surfaceChanged()

## Member Function Documentation

### QWaylandView::QWaylandView(QObject *renderObject = nullptr, QObject *parent = nullptr)

Constructs a QWaylandView with the given renderObject and parent.

### `[override virtual noexcept]` QWaylandView::~QWaylandView()

Destroys the QWaylandView.

### `[virtual]` bool QWaylandView::advance()

Updates the current buffer and damage region to the latest version committed by the client. Returns true if new content was committed since the previous call to advance(). Otherwise returns false.

See also currentBuffer() and currentDamage().

### `[virtual]` void QWaylandView::bufferCommitted(const QWaylandBufferRef &buffer, const QRegion &damage)

This function is called when a new buffer is committed to this view's surface. damage contains the region that is different from the current buffer, i.e. the region that needs to be updated. The new buffer will become current on the next call to advance().

Subclasses that reimplement this function must call the base implementation.

### `[virtual]` QWaylandBufferRef QWaylandView::currentBuffer()

Returns a reference to this view's current buffer.

### `[virtual]` QRegion QWaylandView::currentDamage()

Returns the current damage region of this view.

### `[virtual]` void QWaylandView::discardCurrentBuffer()

Force the view to discard its current buffer, to allow it to be reused on the client side.

### bool QWaylandView::isPrimary() const

Returns true if this QWaylandView is the primary view for the QWaylandSurface

See also QWaylandSurface::primaryView.

### void QWaylandView::setPrimary()

Makes this QWaylandView the primary view for the surface.

It has no effect if this QWaylandView is not holding any QWaylandSurface

See also isPrimary() and QWaylandSurface::primaryView.

### struct wl_resource *QWaylandView::surfaceResource() const

Returns the Wayland surface resource for this QWaylandView.