Skip to content

Commit

Permalink
Resize guac terminal always to absolute pixel width/heigth (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipAB authored Mar 13, 2024
1 parent a02eeed commit 8dba3dd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/app/scenario/guacTerminal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 8dba3dd

Please sign in to comment.