Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(desktop): account for main-window zoom in preview_resize #12718

Closedmacodev00(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/12718/headopened View on GitHub

Showing 3 changed files with 116 additions and 14 deletions.

x
0 of 3 viewed, 3 left
81 additions and 0 deletionsapps/desktop/src/preview/Manager.test.tsModified
View file
@@ -1540,6 +1540,87 @@
+ // Guest innerWidth is CSS pixels of the webview. A frame declared in host CSS
+ // occupies hostCss × windowZoom device pixels; the guest must zoom by that
+ // same window factor (times the preview-only factor) or preview_resize waits
+ // forever for 1280 and sees 2019.
+ effectIt.effect("applies preview zoom times the main window zoom onto the guest", () =>
+ withManager((manager) =>
+ Effect.gen(function* () {
+ const windowZoom = 1.2 ** 2.5;
+ const setZoomFactor = vi.fn();
+ const hostWebContents = Object.assign(makeTestHostWebContents(), {
+ getZoomFactor: () => windowZoom,
+ });
+ const wc = Object.assign(
+ makeTestPreviewWebContents(
+ async () => ({
+ toJPEG: () => Buffer.from("png"),
+ getSize: () => ({ width: 1280, height: 720 }),
+ }),
+ 42,
+ hostWebContents,
+ ),
+ { setZoomFactor },
+ );
+ fromId.mockReturnValue(wc);
+ yield* manager.setMainWindow({
+ isDestroyed: () => false,