Skip to content

Commit e2660c3

Browse files
committed
add pid to window socket info
1 parent d14f525 commit e2660c3

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

mayland-comm/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ pub struct Window {
330330
pub app_id: Option<String>,
331331
/// the window title
332332
pub title: Option<String>,
333+
/// the window process id
334+
pub pid: Option<i32>,
333335

334336
/// the workspace this window is mapped on
335337
pub workspace: usize,

src/comm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ async fn handle_client(mut stream: Async<'_, UnixStream>, state: SocketState) ->
145145
.map(move |(window, geometry)| (window, geometry, workspace))
146146
})
147147
.map(|(window, geometry, workspace)| {
148-
window.comm_info(geometry, workspace, keyboard_focus)
148+
window.comm_info(geometry, workspace, keyboard_focus, &state.mayland.display_handle)
149149
})
150150
.collect();
151151

src/shell/window.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ use smithay::{
1818
},
1919
output::Output,
2020
reexports::{
21-
wayland_protocols::xdg::shell::server::xdg_toplevel, wayland_server::protocol::wl_surface::WlSurface,
21+
wayland_protocols::xdg::shell::server::xdg_toplevel,
22+
wayland_server::{DisplayHandle, Resource, protocol::wl_surface::WlSurface},
2223
},
2324
utils::{IsAlive, Logical, Physical, Point, Rectangle, Scale, Serial, Size},
2425
wayland::{
@@ -447,6 +448,7 @@ impl MappedWindow {
447448
geometry: Rectangle<i32, Logical>,
448449
workspace: &Workspace,
449450
keyboard_focus: Option<&KeyboardFocusTarget>,
451+
display_handle: &DisplayHandle,
450452
) -> mayland_comm::Window {
451453
let active = keyboard_focus.is_some_and(|focus| focus == self);
452454

@@ -479,12 +481,17 @@ impl MappedWindow {
479481
.lock()
480482
.unwrap();
481483

484+
let pid = (display_handle.get_client(xdg.wl_surface().id()).ok())
485+
.and_then(|client| client.get_credentials(display_handle).ok())
486+
.map(|credentials| credentials.pid);
487+
482488
mayland_comm::Window {
483489
relative,
484490
absolute,
485491

486492
app_id: surface_data.app_id.clone(),
487493
title: surface_data.title.clone(),
494+
pid,
488495

489496
workspace: workspace.idx,
490497
active,

0 commit comments

Comments
 (0)