---
name: "wayland_read_intent"
section: "3"
platform: "linux"
package: "waylandpp-dev"
version: "1.0.0-6+b2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/wayland_read_intent"
---

# wayland\_read\_intent(3)

Represents an intention to read from the display file descriptor.

## NAME

wayland::read\_intent - Represents an intention to read from the display file descriptor.

## SYNOPSIS

`#include <wayland-client.hpp>`

### Public Member Functions

bool **is\_finalized** () const\
 Check whether this intent was already finalized with **cancel** or **read**.  void **cancel** ()\
 Cancel read intent.  void **read** ()\
 Read events from display file descriptor.

## Detailed Description

Represents an intention to read from the display file descriptor.

When not using the convenience method **display\_t::dispatch** that takes care of this automatically, threads that want to read events from a Wayland display file descriptor must announce their intention to do so beforehand - in the C API, this is done using wl\_display\_prepare\_read. This intention must then be resolved either by actually invoking a read from the file descriptor or cancelling.

This RAII class makes sure that when it goes out of scope, the intent is cancelled automatically if it was not finalized by manually cancelling or reading before. Otherwise, it would be easy to forget resolving the intent e.g. when handling errors, potentially leading to a deadlock.

Read intents can only be created by a **display\_t** with **display\_t::obtain\_read\_intent** and **display\_t::obtain\_queue\_read\_intent**.

Undefined behavior occurs when the associated **display\_t** or **event\_queue\_t** is destroyed when a **read\_intent** has not been finalized yet.

Definition at line **371** of file **wayland-client.hpp**.

## Member Function Documentation

### void wayland::read\_intent::cancel ()

Cancel read intent. An exception is thrown when the read intent was already finalized.

### bool wayland::read\_intent::is\_finalized () const

Check whether this intent was already finalized with **cancel** or **read**.

### void wayland::read\_intent::read ()

Read events from display file descriptor. This will read events from the file descriptor for the display. This function does not dispatch events, it only reads and queues events into their corresponding event queues. If no data is avilable on the file descriptor, **read()** returns immediately. To dispatch events that may have been queued, call **display\_t::dispatch\_pending** or **display\_t::dispatch\_queue\_pending**.

An exception is thrown when the read intent was already finalized. Each read intent can only be used for reading once. A new one must be obtained for any further read requests.

## Author

Generated automatically by Doxygen for Wayland++ from the source code.
