Fix mpv tile overlap portably; add make install/deploy
mpv 0.35 rejects --auto-window-resize, which crash-looped every player. Drop that flag and re-assert each tile geometry on a 1s timer in the daemon, overriding mpv auto-resize on any mpv version. Add make install (auto-sudo, native build + copy to /usr/local/bin) and make deploy (install + restart the kiosk getty unit). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -153,27 +153,35 @@ func (d *Daemon) applyLayout(ctx context.Context, name string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// placeWhenReady waits for the mpv window to map then tiles it, retrying while
|
||||
// the layout is active (Supervise may relaunch mpv with a new pid).
|
||||
// placeWhenReady waits for the mpv window to map, tiles it, then keeps
|
||||
// re-asserting its geometry on a timer. The re-assertion matters because mpv
|
||||
// resizes its own window to the camera's native resolution when the stream
|
||||
// loads (and mpv 0.35 has no flag to disable that); re-issuing the sway
|
||||
// resize snaps the window back into its cell, portably across mpv versions.
|
||||
func (d *Daemon) placeWhenReady(ctx context.Context, p *player.Player, rect compositor.Rect) {
|
||||
var lastPID int
|
||||
ticker := time.NewTicker(500 * time.Millisecond)
|
||||
var readyPID int
|
||||
ticker := time.NewTicker(1 * time.Second)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
if ctx.Err() != nil {
|
||||
return
|
||||
}
|
||||
pid := p.PID()
|
||||
if pid != 0 && pid != lastPID {
|
||||
if err := d.comp.WaitForWindow(ctx, pid, 15*time.Second); err == nil {
|
||||
if err := d.comp.Place(ctx, pid, rect); err != nil {
|
||||
d.log.Warn("place failed", "slot", p.Slot, "err", err)
|
||||
} else {
|
||||
lastPID = pid
|
||||
d.log.Debug("window placed", "slot", p.Slot, "pid", pid, "rect", rect)
|
||||
if pid != 0 {
|
||||
// New process: wait for its window to map before positioning.
|
||||
if pid != readyPID {
|
||||
if err := d.comp.WaitForWindow(ctx, pid, 15*time.Second); err != nil {
|
||||
goto wait
|
||||
}
|
||||
readyPID = pid
|
||||
d.log.Debug("window mapped", "slot", p.Slot, "pid", pid, "rect", rect)
|
||||
}
|
||||
// Re-assert geometry every tick to override mpv's auto-resize.
|
||||
if err := d.comp.Place(ctx, pid, rect); err != nil {
|
||||
d.log.Debug("place failed", "slot", p.Slot, "err", err)
|
||||
}
|
||||
}
|
||||
wait:
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
|
||||
@@ -67,12 +67,10 @@ func (p *Player) args() []string {
|
||||
"--cursor-autohide=always",
|
||||
"--no-border",
|
||||
"--fullscreen=no", // we tile via the compositor, not fullscreen
|
||||
// Never let mpv resize its own window to the camera's native
|
||||
// resolution — the compositor owns tile geometry. Without this a
|
||||
// high-res camera grows its window and overlaps its neighbours.
|
||||
"--auto-window-resize=no",
|
||||
// Scale video to fill the tile (letterboxed to preserve aspect); the
|
||||
// window size is fixed by the compositor, not by the video.
|
||||
// Keep aspect (letterbox) inside the tile; the compositor owns the
|
||||
// window size, not the video. mpv still resizes its window to the
|
||||
// video resolution on load (and mpv 0.35 lacks the flag to disable
|
||||
// that), so the daemon re-asserts each tile's geometry on a timer.
|
||||
"--keepaspect=yes",
|
||||
"--title=" + p.Title(),
|
||||
"--input-ipc-server=" + p.ipcPath,
|
||||
|
||||
Reference in New Issue
Block a user