diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-11-12 09:09:33 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-11-12 09:37:25 +0300 |
| commit | d193928f315912b67cc997ab4e6f96675695374e (patch) | |
| tree | 4e17af4386b8109897eecb64f9223e4add09d80b /src/window | |
| parent | 17861e0003c122dec9ad8cca1177c750ca6390c8 (diff) | |
| download | niri-d193928f315912b67cc997ab4e6f96675695374e.tar.gz niri-d193928f315912b67cc997ab4e6f96675695374e.tar.bz2 niri-d193928f315912b67cc997ab4e6f96675695374e.zip | |
Add PID to Window IPC
Diffstat (limited to 'src/window')
| -rw-r--r-- | src/window/mapped.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/window/mapped.rs b/src/window/mapped.rs index e9f087bd..b1213c8f 100644 --- a/src/window/mapped.rs +++ b/src/window/mapped.rs @@ -15,7 +15,9 @@ use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; use smithay::reexports::wayland_server::Resource as _; use smithay::utils::{Logical, Point, Rectangle, Scale, Serial, Size, Transform}; use smithay::wayland::compositor::{remove_pre_commit_hook, with_states, HookId}; +use smithay::wayland::seat::WaylandFocus; use smithay::wayland::shell::xdg::{SurfaceCachedState, ToplevelSurface}; +use wayland_backend::server::Credentials; use super::{ResolvedWindowRules, WindowRef}; use crate::handlers::KdeDecorationsModeState; @@ -33,7 +35,9 @@ use crate::render_helpers::surface::render_snapshot_from_surface_tree; use crate::render_helpers::{BakedBuffer, RenderTarget, SplitElements}; use crate::utils::id::IdCounter; use crate::utils::transaction::Transaction; -use crate::utils::{send_scale_transform, with_toplevel_role, ResizeEdge}; +use crate::utils::{ + get_credentials_for_surface, send_scale_transform, with_toplevel_role, ResizeEdge, +}; #[derive(Debug)] pub struct Mapped { @@ -42,6 +46,9 @@ pub struct Mapped { /// Unique ID of this `Mapped`. id: MappedId, + /// Credentials of the process that created the Wayland connection. + credentials: Option<Credentials>, + /// Pre-commit hook that we have on all mapped toplevel surfaces. pre_commit_hook: HookId, @@ -136,9 +143,13 @@ impl InteractiveResize { impl Mapped { pub fn new(window: Window, rules: ResolvedWindowRules, hook: HookId) -> Self { + let surface = window.wl_surface().expect("no X11 support"); + let credentials = get_credentials_for_surface(&surface); + Self { window, id: MappedId::next(), + credentials, pre_commit_hook: hook, rules, need_to_recompute_rules: false, @@ -188,6 +199,10 @@ impl Mapped { self.id } + pub fn credentials(&self) -> Option<&Credentials> { + self.credentials.as_ref() + } + pub fn is_focused(&self) -> bool { self.is_focused } |
