mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-03-20 19:50:55 +03:00
allow deny capture / emulation
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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}"),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user