Skip to main content

basic/
basic.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use glib::prelude::*;
4
5use spice_client_glib::{prelude::*, *};
6
7fn main() {
8    let args: Vec<String> = std::env::args().collect();
9    let session = Session::new();
10    if let Some(uri) = args.get(1) {
11        session.set_uri(Some(uri));
12    } else {
13        session.set_host(Some("localhost"));
14        session.set_port(Some("5900"));
15    }
16
17    session.connect_channel_new(|_, channel| {
18        if let Ok(display) = channel.clone().downcast::<DisplayChannel>() {
19            ChannelExt::connect(&display);
20            display.connect_channel_event(|channel, event| {
21                dbg!((channel, event));
22            });
23            display.connect_gl_scanout_notify(|display| {
24                dbg!(display.gl_scanout().unwrap().fd());
25            });
26            dbg!(display.monitors());
27        }
28    });
29
30    session.connect();
31
32    let main_context = glib::MainContext::default();
33    let main_loop = glib::MainLoop::new(Some(&main_context), false);
34    main_loop.run();
35}