Skip to content

Commit ca9da35

Browse files
fix(device): keep landscape Duo frames upright
1 parent 13a825c commit ca9da35

3 files changed

Lines changed: 24 additions & 4 deletions

File tree

‎apps/web/src/components/device/DeviceDuoControls.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export function DeviceDuoControls(props: {
6161
tabIndex={0}
6262
role="alert"
6363
aria-label={props.state.error}
64-
className="text-xs text-destructive"
64+
className="pointer-events-auto text-xs text-destructive"
6565
>
6666
!
6767
</span>

‎packages/client-runtime/src/device/duoViewer.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,25 @@ it("previews hinge articulation while preserving the laptop lid orientation and
445445
viewer.dispose();
446446
});
447447

448+
it("fills the inner display with native landscape frames without turning them sideways", () => {
449+
const { viewer, drawImage } = fixture();
450+
viewer.setScreen({
451+
width: 2853,
452+
height: 2007,
453+
orientation: "landscape_left",
454+
screenId: 3,
455+
hingeAngle: 90,
456+
hingePose: "laptop",
457+
});
458+
const frame = { width: 2853, height: 2007 } as HTMLCanvasElement;
459+
viewer.frameUpdated(3, frame);
460+
const [source, , , width, height] = drawImage.mock.calls.at(-1)!;
461+
expect(source).toBe(frame);
462+
expect(width).toBeGreaterThan(1550);
463+
expect(height).toBe(1125);
464+
viewer.dispose();
465+
});
466+
448467
it("does not restart an animated preset on duplicate native configurations", async () => {
449468
let now = 100;
450469
vi.stubGlobal("performance", { now: () => now });

‎packages/client-runtime/src/device/duoViewer.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,10 +469,11 @@ export function createDuoViewer(options: {
469469
context.fillStyle = "#080a10";
470470
context.fillRect(0, 0, canvas.width, canvas.height);
471471
context.translate(canvas.width / 2, canvas.height / 2);
472-
if (id === 3) context.rotate(Math.PI / 2);
472+
const rotate = id === 3 && source.height > source.width;
473+
if (rotate) context.rotate(Math.PI / 2);
473474
const scale = Math.min(
474-
canvas.width / (id === 3 ? source.height : source.width),
475-
canvas.height / (id === 3 ? source.width : source.height),
475+
canvas.width / (rotate ? source.height : source.width),
476+
canvas.height / (rotate ? source.width : source.height),
476477
);
477478
context.drawImage(
478479
source,

0 commit comments

Comments
 (0)