← Commit history

1.0.38: 1.0.38: a KiCad window that was busy loading when the bridge tried to send it behind the user's window is now retried until the push lands. The once-per-window slot was claimed before the push, so a refused push (the editor not answering, usual on a slow machine) used the slot up and KiCad stayed in front for good: kicad_open_board left the PCB Editor on top of the user's window on a 2-core VM, twice. A refusal draws no frame, so the retry cannot strobe. Found by the full verb battery on a from-scratch VM, which otherwise passed 117 of 118 verbs on 1.0.37. The wider problem, that every KiCad window takes the foreground for a few milliseconds before it is bounced, is wiki #112 and is not changed here.

John Lauer ·cc7963009c ·1mo ago ·parent 96013fe
1 file changed +10−1
rust/crates/kicad-platform/src/win/etiquette.rs+10−1
@@ -658,7 +658,16 @@ fn handle_foreground(h: u64, source: Source, cache: &mut ExeCache) {             let result = match focus::push_to_background(hwnd(h)) {                 Ok(()) => "pushed",                 Err(e) => {-                    lock().last_error = e;+                    // The once-per-window slot was claimed above, before the push. A REFUSED push moved+                    // nothing (the window is busy loading and does not answer, the usual case on a slow+                    // box), so keeping the slot meant the window was never pushed at all and KiCad stayed+                    // in front for good (winvm, open_board, twice). Give the slot back: the sentinel+                    // tries again in 120 ms and the first push that LANDS is the one that counts. No+                    // strobe is possible, because a refusal draws no frame.+                    let mut g = lock();+                    g.last_error = e;+                    g.backgrounded_once.remove(&(h, pid));+                    g.bounces = g.bounces.saturating_sub(1);                     "push refused (window hung)"                 }             };