sec_context: Fix None drm_node

This commit is contained in:
Victoria Brekenfeld 2023-12-18 12:31:57 +00:00 committed by Victoria Brekenfeld
parent 20160403ac
commit d4d51192b5

View file

@ -32,6 +32,8 @@ impl SecurityContextHandler for State {
.map(|data| data.privileged) .map(|data| data.privileged)
.unwrap_or(false); .unwrap_or(false);
let new_state = state.new_client_state();
let drm_node = client_data let drm_node = client_data
.as_ref() .as_ref()
.and_then(|data| data.downcast_ref::<ClientState>()) .and_then(|data| data.downcast_ref::<ClientState>())
@ -41,7 +43,8 @@ impl SecurityContextHandler for State {
.as_ref() .as_ref()
.and_then(|data| data.downcast_ref::<XWaylandClientData>()) .and_then(|data| data.downcast_ref::<XWaylandClientData>())
.and_then(|data| data.user_data().get::<DrmNode>().cloned()) .and_then(|data| data.user_data().get::<DrmNode>().cloned())
}); })
.or_else(|| new_state.drm_node.clone());
if let Err(err) = state.common.display_handle.insert_client( if let Err(err) = state.common.display_handle.insert_client(
client_stream, client_stream,
@ -51,7 +54,7 @@ impl SecurityContextHandler for State {
&& security_context.sandbox_engine.as_deref() && security_context.sandbox_engine.as_deref()
== Some("com.system76.CosmicPanel"), == Some("com.system76.CosmicPanel"),
drm_node, drm_node,
..state.new_client_state() ..new_state
}), }),
) { ) {
warn!(?err, "Error adding wayland client"); warn!(?err, "Error adding wayland client");