Define a advertised_node_for_client instead of duplicating code

Can't use this in `SecurityContextHandler` since it only has a `ClientId`,
not a `Client`.
This commit is contained in:
Ian Douglas Scott 2024-05-14 12:14:04 -07:00 committed by Victoria Brekenfeld
parent 99fa371ffa
commit 47f8c1da38
2 changed files with 8 additions and 15 deletions

View file

@ -140,9 +140,8 @@ impl ClientData for ClientState {
}
}
pub fn advertised_node_for_surface(w: &WlSurface, dh: &DisplayHandle) -> Option<DrmNode> {
pub fn advertised_node_for_client(client: &Client) -> Option<DrmNode> {
// Lets check the global drm-node the client got either through default-feedback or wl_drm
let client = dh.get_client(w.id()).ok()?;
if let Some(normal_client) = client.get_data::<ClientState>() {
return normal_client.advertised_drm_node.clone();
}
@ -153,6 +152,11 @@ pub fn advertised_node_for_surface(w: &WlSurface, dh: &DisplayHandle) -> Option<
None
}
pub fn advertised_node_for_surface(w: &WlSurface, dh: &DisplayHandle) -> Option<DrmNode> {
let client = dh.get_client(w.id()).ok()?;
advertised_node_for_client(&client)
}
#[derive(Debug)]
pub struct State {
pub backend: BackendData,