allow deny capture / emulation

This commit is contained in:
Ferdinand Schober
2024-07-12 12:46:57 +02:00
parent fa57b4ea34
commit d84c572a4e
6 changed files with 54 additions and 44 deletions

View File

@@ -1,3 +1,4 @@
use ashpd::desktop::ResponseError;
use thiserror::Error;
#[cfg(all(unix, feature = "wayland", not(target_os = "macos")))]
@@ -69,6 +70,18 @@ pub enum CaptureCreationError {
Windows,
}
impl CaptureCreationError {
/// request was intentionally denied by the user
pub(crate) fn cancelled_by_user(&self) -> bool {
match self {
CaptureCreationError::Libei(LibeiCaptureCreationError::Ashpd(
ashpd::Error::Response(ResponseError::Cancelled),
)) => true,
_ => false,
}
}
}
#[cfg(all(unix, feature = "libei", not(target_os = "macos")))]
#[derive(Debug, Error)]
pub enum LibeiCaptureCreationError {

View File

@@ -162,6 +162,7 @@ pub async fn create(
log::info!("using capture backend: {backend}");
return Ok(b);
}
Err(e) if e.cancelled_by_user() => return Err(e),
Err(e) => log::warn!("{backend} input capture backend unavailable: {e}"),
}
}