fix: re-place floating host controls promptly on screen changes

Return to the default corner once it and the current spot are free, and
skip the move confirmation/minimum interval for ~1.5 s after the home <->
voice page switch or a skin switch, so a spot picked for the previous
screen no longer covers controls on the next one (e.g. Export identity).
This commit is contained in:
OddTurtleHead committed 2026-11-15 23:04:31 +08:00
1 parent 2b019d82ff
commit 99d7b86d09
6 files changed
+87 -12

No files matched your search

@@ -47,6 +47,19 @@ test("the default corner is kept while it is free", () => {
assert.deepEqual(choice, { position: "bottom-left", score: 0 });
});
test("a free capsule away from home goes back once the default corner is free, but not while home is busy or under the pointer", () => {
// Left the voice page: the spot picked there is free, and so is home.
const back = chooseFloatingPosition({ current: "middle-right", size: capsule, viewport, margins, obstacles: [], home: "bottom-left" });
assert.deepEqual(back, { position: "bottom-left", score: 0 });
// Home still covers the microphone: stay put (no flapping).
const busy = chooseFloatingPosition({ current: "middle-right", size: capsule, viewport, margins, obstacles: [{ rect: rect(150, 730, 34, 34), weight: FLOATING_WEIGHT_PROTECTED }], home: "bottom-left" });
assert.equal(busy.position, "middle-right");
// The pointer rests on home: do not jump under it.
const pointer: FloatingObstacle = { rect: rect(84, 727, 32, 32), weight: FLOATING_WEIGHT_POINTER };
const underPointer = chooseFloatingPosition({ current: "middle-right", size: capsule, viewport, margins, obstacles: [], moveObstacles: [pointer], home: "bottom-left" });
assert.equal(underPointer.position, "middle-right");
});
test("a capsule over the microphone moves to the first free corner", () => {
// Persona-style dock: microphone at x≈226 under the default capsule.
const obstacles: FloatingObstacle[] = [