Crate calloop_wayland_source

source ·
Expand description

Utilities for using an EventQueue from wayland-client with an event loop that performs polling with calloop.

§Example

use calloop::EventLoop;
use calloop_wayland_source::WaylandSource;
use wayland_client::{Connection, QueueHandle};

// Create a Wayland connection and a queue.
let connection = Connection::connect_to_env().unwrap();
let event_queue = connection.new_event_queue();
let queue_handle = event_queue.handle();

// Create the calloop event loop to drive everytihng.
let mut event_loop: EventLoop<()> = EventLoop::try_new().unwrap();
let loop_handle = event_loop.handle();

// Insert the wayland source into the calloop's event loop.
WaylandSource::new(connection, event_queue).insert(loop_handle).unwrap();

// This will start dispatching the event loop and processing pending wayland requests.
while let Ok(_) = event_loop.dispatch(None, &mut ()) {
    // Your logic here.
}

Structs§

Functions§