mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-22 02:01:55 +07:00
Extract print_window()
This commit is contained in:
+26
-35
@@ -3,7 +3,7 @@ use niri_config::OutputName;
|
|||||||
use niri_ipc::socket::Socket;
|
use niri_ipc::socket::Socket;
|
||||||
use niri_ipc::{
|
use niri_ipc::{
|
||||||
Event, KeyboardLayouts, LogicalOutput, Mode, Output, OutputConfigChanged, Request, Response,
|
Event, KeyboardLayouts, LogicalOutput, Mode, Output, OutputConfigChanged, Request, Response,
|
||||||
Transform,
|
Transform, Window,
|
||||||
};
|
};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|
||||||
@@ -144,19 +144,7 @@ pub fn handle_msg(msg: Msg, json: bool) -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(window) = window {
|
if let Some(window) = window {
|
||||||
println!("Focused window:");
|
print_window(&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)");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
println!("No window is focused.");
|
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));
|
windows.sort_unstable_by(|a, b| a.id.cmp(&b.id));
|
||||||
|
|
||||||
for window in windows {
|
for window in windows {
|
||||||
let focused = if window.is_focused { " (focused)" } else { "" };
|
print_window(&window);
|
||||||
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)");
|
|
||||||
}
|
|
||||||
|
|
||||||
println!();
|
println!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -464,3 +432,26 @@ fn print_output(output: Output) -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
Ok(())
|
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)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user