@@ -91,20 +91,24 @@ def captured() -> bool:
9191
9292
9393def _after_redraw (roost , op ) -> None :
94- """Run `op`, then wait for a fresh paint (the `app.render_stats`
95- draw-call counter ticking) before the caller screenshots — mirrors
96- `test_sprite_pixels`'s D4 wait, so the capture reflects the op's
97- state change and not a stale cached frame. `feed_ime` (and
98- `palette.dismiss`) are synchronous over IPC — the state mutation
99- has already landed by the time `op()` returns — so this only waits
100- for the NEXT paint to pick it up."""
101- roost .call ("app.render_stats" , {"reset" : True })
94+ """Run `op`, then wait for a paint that can only have started after
95+ the mutation. `feed_ime` / `palette.dismiss` are synchronous over
96+ IPC; iced then views+draws on the next frame.
97+
98+ Resetting the counters *before* `op` lets an in-flight pre-op
99+ present count as "the next paint". Wayland `window::screenshot`
100+ copies that last presented buffer, so the capture still shows the
101+ pre-op overlay. Reset after the mutation, then wait for
102+ `view_calls` (chrome, including the palette) and `draw_calls`
103+ (terminal widget, including the preedit overlay)."""
102104 op ()
103- Roost ._wait (
104- lambda : int (roost .call ("app.render_stats" , {})["draw_calls" ]) > 0 ,
105- 5.0 ,
106- "redraw after IME op" ,
107- )
105+ roost .call ("app.render_stats" , {"reset" : True })
106+
107+ def painted () -> bool :
108+ stats = roost .call ("app.render_stats" , {})
109+ return int (stats ["view_calls" ]) > 0 and int (stats ["draw_calls" ]) > 0
110+
111+ Roost ._wait (painted , 2.0 , "redraw after IME op" )
108112
109113
110114@pytest .mark .skipif (
0 commit comments