output/
output.rs

1use std::time::Duration;
2use tokio::{sync::{mpsc, oneshot}, time::sleep};
3use wayland_client::protocol::wl_output::Transform;
4use wayland_protocols_async::zwlr_output_management_v1::handler::{OutputManagementHandler, OutputManagementMessage};
5
6#[tokio::main]
7async fn main() {
8    // create mpsc channel for interacting with the output handler
9    let (output_msg_tx, mut output_msg_rx) = mpsc::channel(128);
10
11    // create mpsc channel for receiving events from the output handler
12    let (output_event_tx, mut output_event_rx) = mpsc::channel(128);
13    
14    // create the handler instance
15    let mut output_handler = OutputManagementHandler::new(output_event_tx);
16
17
18    // start the output handler
19    let output_t = tokio::spawn(async move {
20        let _ = output_handler.run(output_msg_rx).await;
21    });
22
23    // receive all output events
24    let output_event_t = tokio::spawn(async move {
25        loop {
26            let msg = output_event_rx.recv().await;
27            if msg.is_none() {
28                continue;
29            }
30            println!("received output_event event={:?}", msg);
31        }
32    });
33
34    let _ = output_t.await.unwrap();
35    let _ = output_event_t.await.unwrap();
36}