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:
parent
99fa371ffa
commit
47f8c1da38
2 changed files with 8 additions and 15 deletions
|
|
@ -14,12 +14,11 @@ use smithay::{
|
|||
dmabuf::{DmabufFeedbackBuilder, DmabufGlobal},
|
||||
socket::ListeningSocketSource,
|
||||
},
|
||||
xwayland::XWaylandClientData,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
use tracing::{info, warn};
|
||||
|
||||
use crate::state::{ClientState, State};
|
||||
use crate::state::{advertised_node_for_client, ClientState, State};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Socket {
|
||||
|
|
@ -48,17 +47,7 @@ impl State {
|
|||
);
|
||||
|
||||
// initialize globals
|
||||
let filter = move |client: &Client| {
|
||||
if let Some(normal_client) = client.get_data::<ClientState>() {
|
||||
let dev_id = normal_client.advertised_drm_node.unwrap();
|
||||
return dev_id == render_node;
|
||||
}
|
||||
if let Some(xwayland_client) = client.get_data::<XWaylandClientData>() {
|
||||
let dev_id = xwayland_client.user_data().get::<DrmNode>().unwrap();
|
||||
return *dev_id == render_node;
|
||||
}
|
||||
false
|
||||
};
|
||||
let filter = move |client: &Client| advertised_node_for_client(client) == Some(render_node);
|
||||
|
||||
let feedback = DmabufFeedbackBuilder::new(render_node.dev_id(), formats.clone())
|
||||
.build()
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue