summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author1jehuang <[email protected]>2025-12-20 17:18:14 -0800
committer1jehuang <[email protected]>2025-12-20 17:18:14 -0800
commitaae742a3f77c7370ab17e6d8b099f1faefaf7e2d (patch)
tree9a25f9fb908309e8e0a7586b0440675afc27ff11 /src
parentcf5957fb63c8c847d811b724130ff26333b7da99 (diff)
Fix window ordering and mark visible windows
Diffstat (limited to 'src')
-rw-r--r--src/main.rs21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 7a8a1a6..fcdf1e2 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -93,7 +93,7 @@ fn output_status(workspaces: &[Workspace], windows: &[Window]) {
.filter(|w| w.workspace_id == Some(ws.id))
.collect();
- ws_windows.sort_by_key(|w| w.id);
+ ws_windows.sort_by_key(|win| window_sort_key(*win));
let win_count = ws_windows.len();
tooltip.push_str(&format!("ws{}: {} windows\\n", ws.idx, win_count));
@@ -129,7 +129,15 @@ fn output_status(workspaces: &[Workspace], windows: &[Window]) {
"|"
};
- output.push_str(&format!("<span color='{}'>{}</span>", color, bar));
+ let strike = if ws.is_active {
+ " strikethrough=\"true\""
+ } else {
+ ""
+ };
+ output.push_str(&format!(
+ "<span color='{}'{}>{}</span>",
+ color, strike, bar
+ ));
}
output
};
@@ -268,3 +276,12 @@ fn dim_color(hex: &str) -> String {
format!("#{:02x}{:02x}{:02x}", r, g, b)
}
+
+fn window_sort_key(win: &Window) -> (u8, u64, u64, u64) {
+ if let Some((col, row)) = win.layout.pos_in_scrolling_layout {
+ (0, col as u64, row as u64, win.id)
+ } else {
+ // Floating/unknown layout windows go after tiled windows.
+ (1, 0, 0, win.id)
+ }
+}