From 60854e180e692de3ec4acd505936e34a8640f1f6 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Sat, 28 Dec 2024 10:28:52 +0300 Subject: Add is_floating to Window IPC --- niri-ipc/src/lib.rs | 4 ++++ src/ipc/client.rs | 5 +++++ src/ipc/server.rs | 4 +++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/niri-ipc/src/lib.rs b/niri-ipc/src/lib.rs index fea7543f..1d596941 100644 --- a/niri-ipc/src/lib.rs +++ b/niri-ipc/src/lib.rs @@ -758,6 +758,10 @@ pub struct Window { /// /// There can be either one focused window or zero (e.g. when a layer-shell surface has focus). pub is_focused: bool, + /// Whether this window is currently floating. + /// + /// If the window isn't floating then it is in the tiling layout. + pub is_floating: bool, } /// Output configuration change result. diff --git a/src/ipc/client.rs b/src/ipc/client.rs index b2938b61..8682d8d3 100644 --- a/src/ipc/client.rs +++ b/src/ipc/client.rs @@ -516,6 +516,11 @@ fn print_window(window: &Window) { println!(" App ID: (unset)"); } + println!( + " Is floating: {}", + if window.is_floating { "yes" } else { "no" } + ); + if let Some(pid) = window.pid { println!(" PID: {pid}"); } else { diff --git a/src/ipc/server.rs b/src/ipc/server.rs index facb59d3..8828ab1a 100644 --- a/src/ipc/server.rs +++ b/src/ipc/server.rs @@ -412,6 +412,7 @@ fn make_ipc_window(mapped: &Mapped, workspace_id: Option) -> niri_i pid: mapped.credentials().map(|c| c.pid), workspace_id: workspace_id.map(|id| id.get()), is_focused: mapped.is_focused(), + is_floating: mapped.is_floating(), }) } @@ -592,7 +593,8 @@ impl State { }; let workspace_id = ws_id.map(|id| id.get()); - let mut changed = ipc_win.workspace_id != workspace_id; + let mut changed = + ipc_win.workspace_id != workspace_id || ipc_win.is_floating != mapped.is_floating(); changed |= with_toplevel_role(mapped.toplevel(), |role| { ipc_win.title != role.title || ipc_win.app_id != role.app_id -- cgit