Skip to content

Commit

Permalink
server: Implement AsFd for Display so it can be used with calloop
Browse files Browse the repository at this point in the history
  • Loading branch information
ids1024 authored and elinorbgr committed Jul 14, 2023
1 parent 9383041 commit 5774a01
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions wayland-server/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

- Add `flush_clients` method to server `DisplayHandle`.
- Implement `AsFd` for `Display` so it can easily be used in a `calloop` source.

#### Breaking changes

Expand Down
8 changes: 8 additions & 0 deletions wayland-server/src/display.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{os::unix::net::UnixStream, sync::Arc};

use wayland_backend::{
io_lifetimes::{AsFd, BorrowedFd},
protocol::ObjectInfo,
server::{Backend, ClientData, GlobalId, Handle, InitError, InvalidId, ObjectId},
};
Expand Down Expand Up @@ -66,6 +67,13 @@ impl<State: 'static> Display<State> {
}
}

impl<State> AsFd for Display<State> {
/// Provides fd from [`Backend::poll_fd`] for polling.
fn as_fd(&self) -> BorrowedFd<'_> {
self.backend.poll_fd()
}
}

/// A handle to the Wayland display
///
/// A display handle may be constructed from a [`Handle`] using it's [`From`] implementation.
Expand Down

0 comments on commit 5774a01

Please sign in to comment.