cosmic-comp/src/wayland/handlers/security_context.rs

34 lines
1.1 KiB
Rust
Raw Normal View History

use crate::state::{ClientState, State};
use smithay::{
delegate_security_context,
wayland::security_context::{
SecurityContext, SecurityContextHandler, SecurityContextListenerSource,
},
};
use std::sync::Arc;
use tracing::warn;
impl SecurityContextHandler for State {
fn context_created(
&mut self,
source: SecurityContextListenerSource,
security_context: SecurityContext,
) {
self.common
.event_loop_handle
2023-09-29 21:33:16 +02:00
.insert_source(source, move |client_stream, _, state| {
if let Err(err) = state.common.display_handle.insert_client(
client_stream,
Arc::new(ClientState {
security_context: Some(security_context.clone()),
2023-09-29 21:33:16 +02:00
..state.new_client_state()
}),
) {
warn!(?err, "Error adding wayland client");
};
})
.expect("Failed to init the wayland socket source.");
}
}
delegate_security_context!(State);