diff --git a/web/zebra-spaces.html b/web/zebra-spaces.html index 67b32ac..813d2cf 100644 --- a/web/zebra-spaces.html +++ b/web/zebra-spaces.html @@ -1771,9 +1771,26 @@ function renderVideoTile(kind, pubHex, stream, opts){ if (spotlight && spotlight.kind === kind && spotlight.pubHex === pubHex && spotlight.video){ spotlight.video.srcObject = stream; } - /* first arrival auto-spotlights — no spotlight up yet AND this is new */ - if (isNew && !spotlight){ - setSpotlight(kind, pubHex); + /* spotlight promotion rules: + * - no spotlight yet → first tile auto-promotes (anyone) + * - listener role + new SCREEN arrives → auto-promote so the + * audience always sees the most recent share without clicking; + * speakers/hosts get to keep their current focus + * - listener role + new CAMERA → don't override an active screen + * spotlight (cameras are less load-bearing than a screen-share) + */ + if (isNew){ + const isListener = !canSpeak(myRole); + if (!spotlight){ + setSpotlight(kind, pubHex); + } else if (isListener && !local && kind === 'screen' && spotlight.kind !== 'screen'){ + /* listener: a screen just arrived and we're spotlighting a camera + * or game — switch to the screen */ + setSpotlight(kind, pubHex); + } else if (isListener && !local && kind === 'screen' && spotlight.kind === 'screen'){ + /* listener: prefer the newer screen over the older one */ + setSpotlight(kind, pubHex); + } } updateContainerVisibility(); if (isNew) logLine('', k.labelPrefix+' share: '+(local?'local preview ':'receiving ')+label); @@ -3331,8 +3348,8 @@ logLine('', 'ready — pick a handle, type a rendezvous code, enter the space');