ashpd caches zbus::Connection in a global OnceLock. When check_portal_available() created a Screencast proxy, the connection was cached there. When the function returned and its tokio Runtime dropped, the cached connection became dead. Subsequent setup_portal() calls reused this dead connection and hung forever. Fix: replace ashpd Screencast proxy with direct zbus D-Bus interface check, which does not touch the ashpd global connection cache. Add examples/test_portal.rs for minimal Portal ScreenCast testing.
69 lines
2.0 KiB
Rust
69 lines
2.0 KiB
Rust
use ashpd::desktop::screencast::{CursorMode, Screencast, SelectSourcesOptions, SourceType};
|
|
use ashpd::desktop::PersistMode;
|
|
use ashpd::enumflags2::BitFlags;
|
|
|
|
fn main() {
|
|
let rt = tokio::runtime::Runtime::new().unwrap();
|
|
rt.block_on(async {
|
|
eprintln!("1. Creating Screencast proxy...");
|
|
let proxy = match Screencast::new().await {
|
|
Ok(p) => {
|
|
eprintln!(" OK");
|
|
p
|
|
}
|
|
Err(e) => {
|
|
eprintln!(" FAIL: {e}");
|
|
return;
|
|
}
|
|
};
|
|
|
|
eprintln!("2. Creating session...");
|
|
let session = match proxy.create_session(Default::default()).await {
|
|
Ok(s) => {
|
|
eprintln!(" OK");
|
|
s
|
|
}
|
|
Err(e) => {
|
|
eprintln!(" FAIL: {e}");
|
|
return;
|
|
}
|
|
};
|
|
|
|
eprintln!("3. Selecting sources...");
|
|
let sources: BitFlags<SourceType> = SourceType::Monitor.into();
|
|
let result = proxy
|
|
.select_sources(
|
|
&session,
|
|
SelectSourcesOptions::default()
|
|
.set_cursor_mode(CursorMode::Embedded)
|
|
.set_sources(sources)
|
|
.set_multiple(false)
|
|
.set_persist_mode(PersistMode::DoNot),
|
|
)
|
|
.await;
|
|
match result {
|
|
Ok(_) => eprintln!(" OK"),
|
|
Err(e) => {
|
|
eprintln!(" FAIL: {e}");
|
|
return;
|
|
}
|
|
}
|
|
|
|
eprintln!("4. Starting (should show dialog)...");
|
|
let response = match proxy.start(&session, None, Default::default()).await {
|
|
Ok(r) => {
|
|
eprintln!(" OK");
|
|
r
|
|
}
|
|
Err(e) => {
|
|
eprintln!(" FAIL: {e}");
|
|
return;
|
|
}
|
|
};
|
|
match response.response() {
|
|
Ok(r) => eprintln!(" Got {} stream(s)", r.streams().len()),
|
|
Err(e) => eprintln!(" Response error: {e}"),
|
|
}
|
|
});
|
|
}
|