@@ -24,6 +24,7 @@ struct BorderMap { |
| 24 | 24 | focused_wid: u32, |
| 25 | 25 | active_color: (f64, f64, f64, f64), |
| 26 | 26 | inactive_color: (f64, f64, f64, f64), |
| 27 | + active_only: bool, |
| 27 | 28 | } |
| 28 | 29 | |
| 29 | 30 | impl BorderMap { |
@@ -36,6 +37,7 @@ impl BorderMap { |
| 36 | 37 | focused_wid: 0, |
| 37 | 38 | active_color: (0.32, 0.58, 0.89, 1.0), // #5294e2 |
| 38 | 39 | inactive_color: (0.35, 0.35, 0.35, 0.8), // dim gray |
| 40 | + active_only: false, |
| 39 | 41 | } |
| 40 | 42 | } |
| 41 | 43 | |
@@ -200,7 +202,10 @@ impl BorderMap { |
| 200 | 202 | self.focused_wid = front; |
| 201 | 203 | eprintln!("[focus] {} -> {}", old, front); |
| 202 | 204 | |
| 203 | | - // Redraw in-place with new color — no destroy/recreate needed |
| 205 | + if self.active_only { |
| 206 | + self.hide(old); |
| 207 | + self.unhide(front); |
| 208 | + } |
| 204 | 209 | self.redraw(old); |
| 205 | 210 | self.redraw(front); |
| 206 | 211 | } |
@@ -271,6 +276,8 @@ fn main() { |
| 271 | 276 | .and_then(|i| args.get(i + 1)?.parse().ok()) |
| 272 | 277 | .unwrap_or(4.0); |
| 273 | 278 | |
| 279 | + let active_only = args.iter().any(|s| s == "--active-only"); |
| 280 | + |
| 274 | 281 | let cid = unsafe { SLSMainConnectionID() }; |
| 275 | 282 | let own_pid = unsafe { |
| 276 | 283 | let mut pid: i32 = 0; |
@@ -286,6 +293,7 @@ fn main() { |
| 286 | 293 | |
| 287 | 294 | // Discover and create borders |
| 288 | 295 | let mut borders = BorderMap::new(cid, own_pid, border_width); |
| 296 | + borders.active_only = active_only; |
| 289 | 297 | |
| 290 | 298 | if let Some(target) = args.get(1).and_then(|s| s.parse::<u32>().ok()) { |
| 291 | 299 | borders.add_batch(target); |
@@ -302,6 +310,17 @@ fn main() { |
| 302 | 310 | |
| 303 | 311 | borders.update_focus(); |
| 304 | 312 | |
| 313 | + if borders.active_only { |
| 314 | + let focused = borders.focused_wid; |
| 315 | + let to_hide: Vec<u32> = borders.overlays.keys() |
| 316 | + .filter(|&&wid| wid != focused) |
| 317 | + .copied() |
| 318 | + .collect(); |
| 319 | + for wid in to_hide { |
| 320 | + borders.hide(wid); |
| 321 | + } |
| 322 | + } |
| 323 | + |
| 305 | 324 | eprintln!("{} overlays tracked", borders.overlays.len()); |
| 306 | 325 | |
| 307 | 326 | // Process events on background thread with coalescing |
@@ -411,6 +430,9 @@ fn main() { |
| 411 | 430 | pending.remove(&wid); |
| 412 | 431 | if !skip.contains(&wid) { |
| 413 | 432 | borders.add_fresh(wid); |
| 433 | + if borders.active_only && wid != borders.focused_wid { |
| 434 | + borders.hide(wid); |
| 435 | + } |
| 414 | 436 | needs_resubscribe = true; |
| 415 | 437 | } |
| 416 | 438 | } |