mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 12:02:50 +08:00
fix: return floating host controls home only after a screen change
Live re-test of a1c8329 on open-voice-surface desktop: toasts no longer pull the application-library launcher back, but opening the audio-settings modal did. Its backdrop hid "Share accompaniment", the default bottom-right corner looked free, the launcher went home, and right after Esc it still covered the button. 854a488's return-home rule is meant for a stale spot picked for the previous screen, so apply it only within the screen-change window (home <-> voice page, skin switch); on the same screen a free-looking default corner may just be hidden for a moment. The ts3-classic home-return case still passes (it goes through screenChanged()). Browser fixture: modal dialog over the corner (fails on a1c8329 and 854a488).
This commit is contained in:
1 parent
8ca33fd77d
commit
cc36bc4c64
4 files changed
+32
-9
No files matched your search
@@ -160,6 +160,9 @@ export interface FloatingChoice {
|
||||
* order. When `home` (the default corner) is given and both it and `current`
|
||||
* are free, go back home: a spot picked for one screen must not linger over
|
||||
* controls that appear on the next one (e.g. after leaving the voice page).
|
||||
* The binding passes `home` only right after a screen change: on the same
|
||||
* screen a free-looking default corner may just be hidden for a moment (a
|
||||
* modal dialog's backdrop, a toast) and going back there would cover it.
|
||||
* `moveObstacles` (the user's pointer and focused control) only count against
|
||||
* positions the control would move to, so it never jumps under the cursor or
|
||||
* onto the field being typed in.
|
||||
@@ -452,7 +455,11 @@ export function bindFloatingAvoidance(options: FloatingAvoidanceOptions): Floati
|
||||
const rect = focused.getBoundingClientRect();
|
||||
if (rect.width > 0 && rect.height > 0) moveObstacles.push({ rect: toRect(rect), weight: FLOATING_WEIGHT_POINTER });
|
||||
}
|
||||
const full = chooseFloatingPosition({ current: position, size, viewport, margins, obstacles, moveObstacles, home: defaultPosition });
|
||||
const now = Date.now();
|
||||
const urgent = now < urgentUntil;
|
||||
// Return home only after a screen change (see chooseFloatingPosition).
|
||||
const home = urgent ? defaultPosition : undefined;
|
||||
const full = chooseFloatingPosition({ current: position, size, viewport, margins, obstacles, moveObstacles, home });
|
||||
let next = full;
|
||||
let nextCompact = false;
|
||||
if (full.score > 0 && small && small.width > 0 && small.height > 0) {
|
||||
@@ -466,7 +473,6 @@ export function bindFloatingAvoidance(options: FloatingAvoidanceOptions): Floati
|
||||
pendingSince = 0;
|
||||
return;
|
||||
}
|
||||
const now = Date.now();
|
||||
const frozen = now < frozenUntil;
|
||||
if (frozen) {
|
||||
// Frozen at the default corner: hold still, except one escape per
|
||||
@@ -476,7 +482,6 @@ export function bindFloatingAvoidance(options: FloatingAvoidanceOptions): Floati
|
||||
const parkedScore = floatingScore(parked, obstacles);
|
||||
if (frozenEscaped || !(parkedScore > 0 && next.score < parkedScore - 1e-6)) return;
|
||||
}
|
||||
const urgent = now < urgentUntil;
|
||||
if (!urgent && !pendingSince) {
|
||||
pendingSince = now;
|
||||
scheduleConfirm(HOST_FLOATING_MOVE_CONFIRM_MS);
|
||||
|
||||
+17
-3
@@ -57,8 +57,9 @@ try {
|
||||
const accompaniment = document.getElementById("accompaniment");
|
||||
|
||||
// A. A toast keeps passing over the accompaniment button (every mic/output
|
||||
// toggle shows one). The launcher must not take the "free" default corner
|
||||
// while the toast hides the button, and must never end up covering it.
|
||||
// toggle shows one), then a modal dialog hides it. The launcher must not
|
||||
// take the "free" default corner while the button is hidden, and must never
|
||||
// end up covering it.
|
||||
{
|
||||
const { lib, binding } = makeLauncher();
|
||||
binding.revalidate(); await sleep(1400); binding.revalidate(); await sleep(50);
|
||||
@@ -77,7 +78,20 @@ try {
|
||||
}
|
||||
}
|
||||
await sleep(1500);
|
||||
results.push({ name: "toast-transient", settled, positions: [...positions], coveredSamples, samples, final: binding.position, finalCovered: coveredByLib(accompaniment) });
|
||||
// A modal dialog (audio settings) opens over everything: its backdrop
|
||||
// hides the accompaniment button, so the default corner looks free. On the
|
||||
// same screen that is no reason to go back there.
|
||||
const modalPositions = new Set();
|
||||
document.body.insertAdjacentHTML("beforeend", '<div id="backdrop" style="position:fixed;inset:0;z-index:20;background:#0006"></div>'
|
||||
+ '<div id="settings" role="dialog" aria-modal="true" style="position:fixed;left:440px;top:200px;width:400px;height:300px;z-index:21;background:#fff">'
|
||||
+ '<button type="button" id="close-settings" style="margin:16px">Close</button></div>');
|
||||
for (let i = 0; i < 20; i++) { binding.revalidate(); modalPositions.add(binding.position); await sleep(100); }
|
||||
document.getElementById("backdrop").remove();
|
||||
document.getElementById("settings").remove();
|
||||
binding.revalidate();
|
||||
await sleep(100);
|
||||
const afterModal = { positions: [...modalPositions], position: binding.position, accompanimentCovered: coveredByLib(accompaniment) };
|
||||
results.push({ name: "toast-transient", afterModal, settled, positions: [...positions], coveredSamples, samples, final: binding.position, finalCovered: coveredByLib(accompaniment) });
|
||||
binding.dispose();
|
||||
lib.remove();
|
||||
}
|
||||
|
||||
@@ -396,13 +396,17 @@ test("floating host controls see through toasts and still step off a control whi
|
||||
const byName = Object.fromEntries(payload.results.map((result) => [result.name, result]));
|
||||
t.diagnostic(JSON.stringify(payload.results));
|
||||
|
||||
// open-voice-surface desktop: toasts passing over "Share accompaniment" no
|
||||
// longer make the default bottom-right corner look free.
|
||||
// open-voice-surface desktop: toasts passing over "Share accompaniment" (or
|
||||
// the audio-settings modal) no longer make the default corner look free.
|
||||
const toast = byName["toast-transient"];
|
||||
assert.notEqual(toast.settled, "bottom-right", JSON.stringify(toast));
|
||||
assert.ok(!toast.positions.includes("bottom-right"), JSON.stringify(toast));
|
||||
assert.equal(toast.coveredSamples, 0, JSON.stringify(toast));
|
||||
assert.equal(toast.finalCovered, false, JSON.stringify(toast));
|
||||
// Same screen, modal backdrop over the corner: no return home, so the
|
||||
// button is usable the moment the dialog closes.
|
||||
assert.ok(!toast.afterModal.positions.includes("bottom-right"), JSON.stringify(toast));
|
||||
assert.equal(toast.afterModal.accompanimentCovered, false, JSON.stringify(toast));
|
||||
|
||||
// Parked at the default corner by the flap freeze on top of a control: one
|
||||
// escape about 1 s after the freeze (inside the 3 s pin), then still for the rest of it.
|
||||
|
||||
Reference in new issue
Block a user