Place windows at map time so stream restarts never flash
Diagnosis: individual tiles flickered when their stream died and mpv relaunched (confirmed via status: a PID dropping to 0 and coming back). The restarted window mapped at the video's native size wherever sway dropped it, and the corrective loop only snapped it into its cell on the next tick — up to 2s later on the relaxed cadence. Fix, at the source instead of racing the map: - Pre-install a per-slot for_window rule (matched on each mpv's unique window title, anchored so slot-1 never matches slot-10) so sway positions and sizes the window synchronously the moment it maps. - Pass --geometry=WxH per tile so mpv opens at the tile size rather than resizing itself to the video's native size on load. The placeLoop remains as a corrective backstop for mid-life drift. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -177,6 +177,13 @@ func (d *Daemon) applyLayout(ctx context.Context, name string) error {
|
||||
|
||||
for _, s := range specs {
|
||||
p := player.New(s.slot, s.name, s.url, cfg.Player, d.runDir, d.log)
|
||||
p.TileW, p.TileH = s.rect.W, s.rect.H
|
||||
// Pre-install the placement rule so sway positions this slot's window
|
||||
// (including after mid-life mpv restarts) the moment it maps — no
|
||||
// wrong-place flash while waiting for the corrective loop.
|
||||
if err := d.comp.PlaceOnMap(ctx, p.Title(), s.rect); err != nil {
|
||||
d.log.Warn("could not preinstall placement rule", "slot", s.slot, "err", err)
|
||||
}
|
||||
players = append(players, p)
|
||||
places = append(places, placement{p: p, rect: s.rect})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user