From b1e6980b8a7083d2863882da16b87a4068b3ea74 Mon Sep 17 00:00:00 2001 From: philipab Date: Wed, 6 Mar 2024 16:50:18 +0100 Subject: [PATCH] Resize guac terminal always to absolute pixel width/heigth --- src/app/scenario/guacTerminal.component.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app/scenario/guacTerminal.component.ts b/src/app/scenario/guacTerminal.component.ts index 39da89f8..8758e1a9 100644 --- a/src/app/scenario/guacTerminal.component.ts +++ b/src/app/scenario/guacTerminal.component.ts @@ -366,9 +366,9 @@ export class GuacTerminalComponent implements OnChanges { // resize is being called on the hidden window return; } - const pixelDensity = window.devicePixelRatio || 1; - const width = elm.clientWidth * pixelDensity; - const height = elm.clientHeight * pixelDensity; + const pixelDensity = window.devicePixelRatio || 1; // window.devicePixelRatio is a floating number + const width = Math.floor(elm.clientWidth * pixelDensity); + const height = Math.floor(elm.clientHeight * pixelDensity); return { width: width, height: height }; } @@ -401,8 +401,8 @@ export class GuacTerminalComponent implements OnChanges { // setting timeout so display has time to get the correct size setTimeout(() => { const scale = Math.min( - elm.clientWidth / Math.max(this.display.getWidth(), 1), - elm.clientHeight / Math.max(this.display.getHeight(), 1), + Math.floor(elm.clientWidth / Math.max(this.display.getWidth(), 1)), + Math.floor(elm.clientHeight / Math.max(this.display.getHeight(), 1)), ); this.display.scale(scale); }, 100);