diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-09-06 18:25:47 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-09-06 18:32:51 +0300 |
| commit | 7d11ef0abb88f18b4c5380aa9bea6c684fc39765 (patch) | |
| tree | ec10ac187f976b84f95095fd5ceed6da3ffc1676 | |
| parent | dcb29efce58ce0e122806b7f352a9f682e2fcbd8 (diff) | |
| download | niri-7d11ef0abb88f18b4c5380aa9bea6c684fc39765.tar.gz niri-7d11ef0abb88f18b4c5380aa9bea6c684fc39765.tar.bz2 niri-7d11ef0abb88f18b4c5380aa9bea6c684fc39765.zip | |
Extract print_window()
| -rw-r--r-- | src/ipc/client.rs | 61 |
1 files changed, 26 insertions, 35 deletions
diff --git a/src/ipc/client.rs b/src/ipc/client.rs index fcbf4b8c..472daab2 100644 --- a/src/ipc/client.rs +++ b/src/ipc/client.rs @@ -3,7 +3,7 @@ use niri_config::OutputName; use niri_ipc::socket::Socket; use niri_ipc::{ Event, KeyboardLayouts, LogicalOutput, Mode, Output, OutputConfigChanged, Request, Response, - Transform, + Transform, Window, }; use serde_json::json; @@ -144,19 +144,7 @@ pub fn handle_msg(msg: Msg, json: bool) -> anyhow::Result<()> { } if let Some(window) = window { - println!("Focused window:"); - - if let Some(title) = window.title { - println!(" Title: \"{title}\""); - } else { - println!(" Title: (unset)"); - } - - if let Some(app_id) = window.app_id { - println!(" App ID: \"{app_id}\""); - } else { - println!(" App ID: (unset)"); - } + print_window(&window); } else { println!("No window is focused."); } @@ -176,27 +164,7 @@ pub fn handle_msg(msg: Msg, json: bool) -> anyhow::Result<()> { windows.sort_unstable_by(|a, b| a.id.cmp(&b.id)); for window in windows { - let focused = if window.is_focused { " (focused)" } else { "" }; - println!("Window ID {}:{focused}", window.id); - - if let Some(title) = window.title { - println!(" Title: \"{title}\""); - } else { - println!(" Title: (unset)"); - } - - if let Some(app_id) = window.app_id { - println!(" App ID: \"{app_id}\""); - } else { - println!(" App ID: (unset)"); - } - - if let Some(workspace_id) = window.workspace_id { - println!(" Workspace ID: {workspace_id}"); - } else { - println!(" Workspace ID: (none)"); - } - + print_window(&window); println!(); } } @@ -464,3 +432,26 @@ fn print_output(output: Output) -> anyhow::Result<()> { } Ok(()) } + +fn print_window(window: &Window) { + let focused = if window.is_focused { " (focused)" } else { "" }; + println!("Window ID {}:{focused}", window.id); + + if let Some(title) = &window.title { + println!(" Title: \"{title}\""); + } else { + println!(" Title: (unset)"); + } + + if let Some(app_id) = &window.app_id { + println!(" App ID: \"{app_id}\""); + } else { + println!(" App ID: (unset)"); + } + + if let Some(workspace_id) = window.workspace_id { + println!(" Workspace ID: {workspace_id}"); + } else { + println!(" Workspace ID: (none)"); + } +} |
