feat: gate semantic effects by client capability
This commit is contained in:
1 parent
6d19932a64
commit
a6ec721437
9 files changed
+387
-5
No files matched your search
@@ -4,7 +4,7 @@ use std::ffi::OsString;
|
||||
|
||||
use smithay::reexports::calloop::EventLoop;
|
||||
|
||||
use crate::Ferese;
|
||||
use crate::{Ferese, private_client::ClientCapabilities};
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum BackendKind {
|
||||
@@ -16,6 +16,7 @@ pub enum BackendKind {
|
||||
pub struct LaunchConfig {
|
||||
pub backend: BackendKind,
|
||||
pub client: Vec<OsString>,
|
||||
pub client_capabilities: ClientCapabilities,
|
||||
}
|
||||
|
||||
impl LaunchConfig {
|
||||
@@ -33,6 +34,7 @@ impl LaunchConfig {
|
||||
let mut args = args.into_iter().peekable();
|
||||
let mut requested_backend = None;
|
||||
let mut client = Vec::new();
|
||||
let mut client_capabilities = ClientCapabilities::default();
|
||||
|
||||
while let Some(argument) = args.next() {
|
||||
if argument == "--" {
|
||||
@@ -46,6 +48,10 @@ impl LaunchConfig {
|
||||
requested_backend = Some(parse_backend(&value)?);
|
||||
continue;
|
||||
}
|
||||
if argument == "--grant-effects" {
|
||||
client_capabilities.insert(ClientCapabilities::EFFECTS);
|
||||
continue;
|
||||
}
|
||||
if let Some(value) = argument
|
||||
.to_str()
|
||||
.and_then(|argument| argument.strip_prefix("--backend="))
|
||||
@@ -65,7 +71,11 @@ impl LaunchConfig {
|
||||
BackendKind::Drm
|
||||
});
|
||||
|
||||
Ok(Self { backend, client })
|
||||
Ok(Self {
|
||||
backend,
|
||||
client,
|
||||
client_capabilities,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,6 +112,7 @@ mod tests {
|
||||
|
||||
assert_eq!(config.backend, BackendKind::Nested);
|
||||
assert_eq!(config.client, [OsString::from("foot")]);
|
||||
assert!(config.client_capabilities.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -110,6 +121,7 @@ mod tests {
|
||||
|
||||
assert_eq!(config.backend, BackendKind::Drm);
|
||||
assert!(config.client.is_empty());
|
||||
assert!(config.client_capabilities.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -130,6 +142,26 @@ mod tests {
|
||||
config.client,
|
||||
[OsString::from("foot"), OsString::from("--title=Ferese")]
|
||||
);
|
||||
assert!(config.client_capabilities.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn explicitly_grants_effects_to_the_launched_private_client() {
|
||||
let config = LaunchConfig::parse(
|
||||
[
|
||||
OsString::from("--grant-effects"),
|
||||
OsString::from("ferese-effects-probe"),
|
||||
],
|
||||
true,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(config.client, [OsString::from("ferese-effects-probe")]);
|
||||
assert!(
|
||||
config
|
||||
.client_capabilities
|
||||
.contains(ClientCapabilities::EFFECTS)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user