diff options
Diffstat (limited to 'src/utils/mod.rs')
| -rw-r--r-- | src/utils/mod.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 3d40d890..0b75966b 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -16,12 +16,16 @@ use smithay::output::{self, Output}; use smithay::reexports::rustix::time::{clock_gettime, ClockId}; use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel; use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; +use smithay::reexports::wayland_server::{DisplayHandle, Resource as _}; use smithay::utils::{Coordinate, Logical, Point, Rectangle, Size, Transform}; use smithay::wayland::compositor::{send_surface_state, with_states, SurfaceData}; use smithay::wayland::fractional_scale::with_fractional_scale; use smithay::wayland::shell::xdg::{ ToplevelSurface, XdgToplevelSurfaceData, XdgToplevelSurfaceRoleAttributes, }; +use wayland_backend::server::Credentials; + +use crate::niri::ClientState; pub mod id; pub mod scale; @@ -244,6 +248,19 @@ pub fn with_toplevel_role<T>( }) } +pub fn get_credentials_for_surface(surface: &WlSurface) -> Option<Credentials> { + let handle = surface.handle().upgrade()?; + let dh = DisplayHandle::from(handle); + + let client = dh.get_client(surface.id()).ok()?; + let data = client.get_data::<ClientState>().unwrap(); + if data.credentials_unknown { + return None; + } + + client.get_credentials(&dh).ok() +} + #[cfg(feature = "dbus")] pub fn show_screenshot_notification(image_path: Option<PathBuf>) { let mut notification = notify_rust::Notification::new(); |
