Prefer grid mode in landscape on mobile

This commit is contained in:
Robin
2026-07-14 16:50:34 +02:00
parent 5c35288162
commit 7962d02be5
3 changed files with 27 additions and 31 deletions

View File

@@ -568,14 +568,14 @@ describe.each([
pipSize: "sm", pipSize: "sm",
}, },
b: { b: {
type: "spotlight-expanded", type: "spotlight-landscape",
spotlight: [`${aliceId}:0:screen-share`], spotlight: [`${aliceId}:0:screen-share`],
pip: `${aliceId}:0`, grid: [`${localId}:0`, `${aliceId}:0`],
}, },
c: { c: {
type: "spotlight-expanded", type: "spotlight-landscape",
spotlight: [`${aliceId}:0`], spotlight: [`${aliceId}:0`],
pip: undefined, grid: [`${localId}:0`, `${bobId}:0`],
}, },
}, },
); );

View File

@@ -39,15 +39,16 @@ function testLayoutSwitch({
} }
describe("default mode", () => { describe("default mode", () => {
test("uses grid layout by default", () => test("uses grid layout in normal window", () =>
testLayoutSwitch({ testLayoutSwitch({
windowMode: " n",
expectedGridMode: "g", expectedGridMode: "g",
})); }));
test("uses spotlight mode when window mode is flat", () => test("uses grid layout in flat window", () =>
testLayoutSwitch({ testLayoutSwitch({
windowMode: " f", windowMode: " f",
expectedGridMode: "s", expectedGridMode: "g",
})); }));
}); });
@@ -101,32 +102,25 @@ test("switches manually to grid after screen share while manually in spotlight",
expectedGridMode: "gs-g", expectedGridMode: "gs-g",
})); }));
test("auto-switches to spotlight when in flat window mode", () =>
testLayoutSwitch({
// First normal, then narrow, then flat.
windowMode: " nNf",
expectedGridMode: "g-s",
}));
test("allows switching modes manually when in flat window mode", () => test("allows switching modes manually when in flat window mode", () =>
testLayoutSwitch({ testLayoutSwitch({
// Window becomes flat, then user switches to grid and back. // Window becomes flat, then user switches to spotlight and back.
// Finally the window returns to a normal shape. // Finally the window returns to a normal shape.
windowMode: " nf--n", windowMode: " nf--n",
userSelection: " --gs", userSelection: " --sg",
expectedGridMode: "gsgsg", expectedGridMode: "g-sg",
})); }));
test("stays in spotlight while there are screen shares even when window mode changes", () => test("switches to grid when in flat window mode even when there are screen shares", () =>
testLayoutSwitch({ testLayoutSwitch({
windowMode: " nfn", windowMode: " nf",
hasScreenShares: " y", hasScreenShares: " y",
expectedGridMode: "s", expectedGridMode: "sg",
})); }));
test("ignores end of screen share until window mode returns to normal", () => test("ignores screen share until window mode returns to normal", () =>
testLayoutSwitch({ testLayoutSwitch({
windowMode: " nf-n", windowMode: " f-n",
hasScreenShares: " y-n", hasScreenShares: " ny-n",
expectedGridMode: "s--g", expectedGridMode: "g-sg",
})); }));

View File

@@ -48,13 +48,15 @@ export function createLayoutModeSwitch(
const naturalGridMode$ = scope.behavior<GridMode>( const naturalGridMode$ = scope.behavior<GridMode>(
combineLatest( combineLatest(
[hasRemoteScreenShares$, windowMode$], [hasRemoteScreenShares$, windowMode$],
(hasRemoteScreenShares, windowMode) => (hasRemoteScreenShares, windowMode) => {
// When there are screen shares or the window is flat (as with a phone // When the window is flat (as with a phone in landscape orientation),
// in landscape orientation), spotlight is a better experience. // grid mode is preferable as there's usually more than enough
// We want screen shares to be big and readable, and we want flipping // horizontal space to fit in some grid tiles on the side.
// your phone into landscape to be a quick way of maximising the if (windowMode === "flat") return "grid";
// spotlight tile. // When there are screen shares, spotlight is a better experience. We
hasRemoteScreenShares || windowMode === "flat" ? "spotlight" : "grid", // want them to be big and readable.
return hasRemoteScreenShares ? "spotlight" : "grid";
},
), ),
); );