@@ -223,6 +223,8 @@ fn main() { |
| 223 | 223 | // Deduplicate: track which wids need move vs resize |
| 224 | 224 | let mut moved: HashSet<u32> = HashSet::new(); |
| 225 | 225 | let mut resized: HashSet<u32> = HashSet::new(); |
| 226 | + let mut created: HashSet<u32> = HashSet::new(); |
| 227 | + let mut destroyed: HashSet<u32> = HashSet::new(); |
| 226 | 228 | |
| 227 | 229 | for event in events { |
| 228 | 230 | match event { |
@@ -238,14 +240,16 @@ fn main() { |
| 238 | 240 | } |
| 239 | 241 | Event::Close(wid) | Event::Destroy(wid) => { |
| 240 | 242 | if !borders.is_overlay(wid) { |
| 241 | | - borders.remove(wid); |
| 243 | + destroyed.insert(wid); |
| 244 | + created.remove(&wid); |
| 242 | 245 | moved.remove(&wid); |
| 243 | 246 | resized.remove(&wid); |
| 244 | 247 | } |
| 245 | 248 | } |
| 246 | 249 | Event::Create(wid) => { |
| 247 | 250 | if !borders.is_overlay(wid) { |
| 248 | | - borders.add_fresh(wid); |
| 251 | + created.insert(wid); |
| 252 | + // Subscribe immediately so we get Move/Resize for it |
| 249 | 253 | borders.subscribe_target(wid); |
| 250 | 254 | } |
| 251 | 255 | } |
@@ -255,8 +259,9 @@ fn main() { |
| 255 | 259 | } |
| 256 | 260 | } |
| 257 | 261 | |
| 258 | | - if !moved.is_empty() || !resized.is_empty() { |
| 259 | | - eprintln!("[batch] moved={:?}, resized={:?}", moved, resized); |
| 262 | + // Process destroys first |
| 263 | + for wid in &destroyed { |
| 264 | + borders.remove(*wid); |
| 260 | 265 | } |
| 261 | 266 | |
| 262 | 267 | // Process moves (just reposition, fast) |
@@ -272,6 +277,14 @@ fn main() { |
| 272 | 277 | borders.recreate(*wid); |
| 273 | 278 | } |
| 274 | 279 | } |
| 280 | + |
| 281 | + // Process creates: only add if NOT destroyed in same batch |
| 282 | + // and if the window has been moved/resized (tarmac positioned it) |
| 283 | + for wid in &created { |
| 284 | + if !destroyed.contains(wid) && (moved.contains(wid) || resized.contains(wid)) { |
| 285 | + borders.add_fresh(*wid); |
| 286 | + } |
| 287 | + } |
| 275 | 288 | } |
| 276 | 289 | }); |
| 277 | 290 | |