From 2ff9399e04f0eb4c4743826bb26ebf633545348d Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 3 Jan 2024 15:38:06 +0100 Subject: [PATCH] Slintpad: resize the cansvas after showing the UI Right now, the winit window adaptor will force a px value on the width and height once the ui is up. We should then override that again with 100% after the UI is shown --- editors/vscode/src/wasm_preview.ts | 6 +++++- tools/slintpad/src/preview_widget.ts | 8 +++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/editors/vscode/src/wasm_preview.ts b/editors/vscode/src/wasm_preview.ts index d2c2ff2f367..da464ea18ad 100644 --- a/editors/vscode/src/wasm_preview.ts +++ b/editors/vscode/src/wasm_preview.ts @@ -164,7 +164,11 @@ function getPreviewHtml( } }); - preview_connector.show_ui().then(() => vscode.postMessage({ command: 'preview_ready' })); + preview_connector.show_ui().then(() => { + canvas.style.width = "100%"; + canvas.style.height = "100%"; + vscode.postMessage({ command: 'preview_ready' }); + }); diff --git a/tools/slintpad/src/preview_widget.ts b/tools/slintpad/src/preview_widget.ts index 7c719818fcd..1fdc6813902 100644 --- a/tools/slintpad/src/preview_widget.ts +++ b/tools/slintpad/src/preview_widget.ts @@ -25,11 +25,6 @@ export class PreviewWidget extends Widget { canvas.style.height = "100%"; canvas.style.outline = "none"; canvas.style.touchAction = "none"; - canvas.width = canvas.offsetWidth; - canvas.height = canvas.offsetHeight; - - canvas.dataset.slintAutoResizeToPreferred = "false"; - node.appendChild(canvas); return node; @@ -56,6 +51,9 @@ export class PreviewWidget extends Widget { // when searching the document. this.#previewer.show_ui().then(() => { console.info("UI should be up!"); + const canvas = document.getElementById(canvas_id) as HTMLElement; + canvas.style.width = "100%"; + canvas.style.height = "100%"; }); }); }