Make wlgrid a chooser only, and say what each format is
--focus and sway::focus are gone. Showing the grid and reporting the choice is the whole job; deciding what the choice means belongs to whoever called it, and keeping that decision here only invited more of it (focus which way? move? swap? scratchpad?). The sway IPC connection is now scoped to building the list and closed before the overlay maps. --help no longer just names the three formats, it shows them. Each gets a real sample line, what every column means, and where the format is meant to be used: tsv for `IFS=$'\t' read` or cut, json for jq, portal for xdg-desktop-portal-wlr's simple chooser, with the config stanza to paste. Plus worked examples of focusing a window, handling either kind of pick, and screenshotting one with grim -T.
This commit is contained in:
+5
-15
@@ -1,7 +1,9 @@
|
||||
//! sway stays the source of truth for the window list and for focusing, exactly
|
||||
//! as the shell script this replaces did (`swaymsg -t get_tree` + `[con_id=N]
|
||||
//! focus`). The Wayland side only supplies pixels; the join between the two is
|
||||
//! sway is the source of truth for the window list (`swaymsg -t get_tree`); the
|
||||
//! Wayland side only supplies pixels. The join between the two is
|
||||
//! `foreign_toplevel_identifier`, which sway reports per view.
|
||||
//!
|
||||
//! Acting on the choice is deliberately not here: wlgrid reports what was picked
|
||||
//! and the caller decides what that means.
|
||||
|
||||
use swayipc::{Connection, Node, NodeType};
|
||||
|
||||
@@ -47,15 +49,3 @@ pub fn scale(conn: &mut Connection) -> Result<i32, swayipc::Error> {
|
||||
.unwrap_or(1)
|
||||
.max(1))
|
||||
}
|
||||
|
||||
pub fn focus(conn: &mut Connection, target: &Target) -> Result<(), swayipc::Error> {
|
||||
let cmd = match target.con_id {
|
||||
Some(con_id) => format!("[con_id={con_id}] focus"),
|
||||
// Picking a display means going to it.
|
||||
None => format!("focus output {}", target.id),
|
||||
};
|
||||
for res in conn.run_command(cmd)? {
|
||||
res?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user